Im making a script so that if a certain variable is true and the player has clicked their mouse that it will play an animation. The animation is working, but when i change the value of a variable in the script, it doesnt change it.
local userinputservice = game:GetService("UserInputService")
local animationPlaying = false
local animationBegan = game.ReplicatedStorage.animationBegan
animationBegan.OnServerEvent:Connect(function(player)
local humanoid = player.Character.Humanoid
local animation = humanoid:LoadAnimation(script.animation)
userinputservice.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
animationPlaying = true
animation:Play()
wait(1)
animationPlaying = false
end
end)
if animationPlaying == true then
print("animation is Playing")
end
When I run that script and I click, it never prints "animation is Playing" meaning that the value wasn't changed. How do I change the value of a variable after I create it?

1 comment
It worked! Thanks