Theres a bug in my game

im makeing a game like minecraft but i cant get it to delete blocks and i dont know hot to fix it theres a error that says “Argument of type ‘boolean’ is not assignable to parameter of type ‘() => void’.”
the game is CoSpaces Edu :: cocraft

Hi @Matthew_Leach :slight_smile:

Here’s the corrected part of the code that resulted in an error:

Input.onKeyPressed(() => {
    const rayCastHit = RayCast.cast( Camera.transform.position , Input.clickDirection )
    let item = rayCastHit.item
    if (item !== undefined) {
       item.delete()
    }
}, "r");
1 Like

thank you for helping the code is finally working and do you know if I could put a 0.1 second cool down and thx for the code

Hi @Matthew_Leach yes, feel free to try this and let us know if you get the results you’re looking for:

let cooldownTime = 0.1
let lastRemoveTime = 0
Input.onKeyPressed(() => {
    let currentTime = Time.currentTime
    if (currentTime - lastRemoveTime > cooldownTime) {
        const rayCastHit = RayCast.cast( Camera.transform.position , Input.clickDirection )
        let item = rayCastHit.item
        if (item !== undefined) {
            item.delete()
        }
        lastRemoveTime = currentTime
    }
}, "r");
2 Likes

thank you now its finaly fully working now im going to upload the first version

1 Like