local tool = script.Parent
local isSwinging = tool.isSwinging
local animation = tool.Animation
isSwinging = false
tool.Activated:Connect(function()
if isSwinging == false then
isSwinging = true
local character = tool.Parent
local humanoid = character.Humanoid
print(isSwinging)
local AnimationTrack = humanoid:LoadAnimation(animation)
AnimationTrack:Play()
wait(0.45)
isSwinging = false
print(isSwinging)
end
end)
If there are better practices, I would like to know!
When working with bool values you need to access the .Value property to change its value (same thing with other value instances), in this case to solve your issue, simply add .Value (directly after isSwinging) in the following places:
Here
Here
Here
And here.
Basically why it was “changing in the script” but not studio was because on this line:
You essentially made the variable just true or false and not the isSwinging value, so that variable was changed from there on and not the actual bool value since you forgot .Value
isSwinging should be changed about its isSwinging.Value when you are talking about the BoolValue. Changing the variable directly will result in changing the entire variable pointing to a boolean instead.