I want the animation to play if the player is not idle and the tool is also equipped
so if the player is walking and the tool is also equipped then he animation plays and their speed turns to 32
but if they unequip it
it does the opposite
local script inside tool:
local rem = game:GetService("ReplicatedStorage").RemoteEvent
local rem2 = game:GetService("ReplicatedStorage").rem2
local tool = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local humwalkspeed = hum.WalkSpeed
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://9255499096"
local track = hum:LoadAnimation(animation)
local toolequipped = false
tool.Equipped:Connect(function()
hum.Running:Connect(function(speed)
if toolequipped == false then
toolequipped = true
if toolequipped == false and speed <= 0 then return end
if speed > 0 and toolequipped == true then
track:Play()
rem:FireServer()
print("fired")
end
end
end)
end)
tool.Unequipped:Connect(function()
if toolequipped == true then
toolequipped = false
track:Stop()
rem2:FireServer(humwalkspeed)
end
end)