I am trying to create a tool that plays a custom animation and changes the walkspeed to 4 and turns the player back to normal when they unequip the tool.
The equip function works perfectly however the players walk animation is still the same and the players walkspeed is still 4 when they unequip the tool.
I tried putting the humanoid variable on the first line but it didn’t work.
script.Parent.Equipped:Connect(function()
local Humanoid = script.Parent.Parent:WaitForChild("Humanoid")
Humanoid.WalkSpeed = 4
local AnimateWalk = script.Parent.Parent:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
AnimateWalk.AnimationId = "rbxassetid://6121017216"
end)
script.Parent.Unequipped:Connect(function()
local Humanoid = script.Parent.Parent:WaitForChild("Humanoid")
Humanoid.WalkSpeed = 16
local AnimateWalk = script.Parent.Parent:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
AnimateWalk.AnimationId = "rbxassetid://913402848"
end)
Okay so I think that is the problem but now I can’t find the character.
I tried making the players name a variable and then searching the workspace for the variable but it gives no errors but still doesn’t work.
script.Parent.Equipped:Connect(function()
local Humanoid = script.Parent.Parent:WaitForChild("Humanoid")
Humanoid.WalkSpeed = 4
local AnimateWalk = script.Parent.Parent:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
AnimateWalk.AnimationId = "rbxassetid://6121017216"
end)
script.Parent.Unequipped:Connect(function(plr)
local Name = script.Parent.Parent.Parent.Name
local character = workspace:FindFirstChild(Name)
local Humanoid = character:WaitForChild("Humanoid")
local AnimateWalk = character:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
AnimateWalk.AnimationId = "rbxassetid://913402848"
end)
local Humanoid = character:WaitForChild("Humanoid") local AnimateWalk = character:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
That is what I did however it gives off no errors but still doesn’t work.
script.Parent.Unequipped:Connect(function(plr)
local Name = script.Parent.Parent.Parent.Name
local character = workspace:FindFirstChild(Name)
local Humanoid = character:WaitForChild("Humanoid")
local AnimateWalk = character:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
AnimateWalk.AnimationId = "rbxassetid://913402848"
end)
It saves the players name inside game.Players btw.
Well maybe the problem is, while a player playing an animation by animate script then it won’t change the current animation to the new one. Because it’s already playing. I mean you can’t see any change while walking. I am using modules or local scripts for tool scripts like this.
Also looks like you added an extra “.Parent” from your earlier code which, if you haven’t changed the
script structure since, would try to get the name of the workspace instead of the Character/Model.