When trying to use an event on a boolean value, I get “Attempt to index boolean with ‘Changed’”.
I looked around but solutions to similar issues weren’t helping. The Boolean Value is in Server Storage.
Shortened version of the code with everything related to the issue.
local serverStorage = game:GetService("ServerStorage")
local skipAnimation = serverStorage.SkipAnimation
local animationsList = {} --Gets loaded with various AnimationTracks
local function ChangeSkipValue()
if not skipAnimation.Value then
skipAnimation.Value = true
end
end
for _, playingAnimation in pairs(animationsList) do
playingAnimation:Play()
playingAnimation.Ended:Once(ChangeSkipValue)
skipAnimation.Changed:Wait()
--disconnect events here
skipAnimation = false
end
Do you seriously not see the problem? You forgot to add .Value to the assignee, which means you are just setting the variable skipAnimation to false, not the underlying value of what skipAnimation represents. Thus, when you try to call skipAnimation later, you are just getting a boolean because that is what you just set it as.
It should be
skipAnimation.Value = false
I’m noticing a trend here where people still come asking for help even though the error messages are trivially easy to understand. It literally tells you that you are trying to index a boolean (not possible), which should immediately tell you that you made a mistake setting the value of that variable. Please for the love of god read the error message. It will save both your time and the people trying to help.