I want to make a tool script that when a player equips it changes the players walkspeed and then changes the players walk animation and reverts everything back once they unequip.
The player’s walkspeed gets lowered but the the walk animation doesn’t change whatsoever.
I have tried changing the players walk animation in the animate script when the tool gets equipped but it doesn’t work.
Edit: I used Humanoid.MovementDirection but now it starts playing the walk anim as soon as the player equips and doesn’t stop when unequipped.
I placed the new script below
local Animation = script.Walk
script.Parent.Equipped:Connect(function()
local Humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local LoadedAnimation = Humanoid:LoadAnimation(Animation)
LoadedAnimation:Play()
Humanoid.WalkSpeed = 4
if Humanoid.MoveDirection.Magnitude >= 0 then
LoadedAnimation:Play()
elseif Humanoid.MoveDirection.Magnitude == 0 then
LoadedAnimation:Stop()
end
end)
script.Parent.Unequipped:Connect(function()
local Name = script.Parent.Parent.Parent.Name
local character = game.Workspace:FindFirstChild(Name)
local Humanoid = character:WaitForChild("Humanoid")
local LoadedAnimation = Humanoid:LoadAnimation(Animation)
LoadedAnimation:Play()
Humanoid.WalkSpeed = 16
local AnimateWalk = character:WaitForChild("Animate"):WaitForChild("walk"):WaitForChild("WalkAnim")
AnimateWalk.AnimationId = "rbxassetid://913402848"
end)
