'=' expected near 'Jumpscare"

'=' expected near 'Jumpscare"

Problem Description:

local Jumpscare = 0

function onUpdate()
    setProperty('cpuControlled', false)
    setProperty Jumpscare = 1
    return
end

function onUpdate()
    if Jumpscare = 1 then
        playSound('PIRACY_IS_ILLEGAL!')
    end
    
end

code does not work
please help anyone

i tried playing a sound over and over again on a cpuControlled event but it just dosent work

Solution – 1

Well, when you compare something in Lua and many other languages, especially when you want to know if they’re equal, then you should use a double equal sign:

if Jumpscare == 1 then
    playSound('PIRACY_IS_ILLIGAL')
end

This is because "=" are used to set a variable to a certain value. In english your code says:

if … Btw Jumpscare is equal to one. … then

Instead, you would want it to say:

if Jumpscare is equal to one, then…

Hence the "==" !
Have a good day and remember to use "==" when comparing values 😀

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject