If Statement not working

Basically how this script works if if the player doesn’t have put (not haspuck) it will activate, and then once the puck touches the stick, haspuck = true. Now when haspuck = true (if haspuck == true then) its supposed to play an animation. However, I have to reequip the stick if i want the animation to play afterwards: https://gyazo.com/c12386d7bcd51d824b415e00ec83d83f

How can I make it so when haspuck = true it automatically activates the animation?

I would change haspuck to become a booleanValue (object) then use

haspuck:GetPropertyChangedSignal("Value"):Connect(function()
    if haspuck.Value == true then
        -- Activate.
    end
end

boolvalues are unnecessary, if you want to just do some Changed event, you can use some table proxies. Also
if haspuck.Value == true then is the same as if haspuck.Value then

local function haspuckUpdate()
    if haspuck then
        --yes
    else
        --no
    end
end

whenever your code changes haspuck, just call haspuckUpdate() right after it

1 Like