Hey, I am making a tool system and when a player equips a tool it is supposed to play an animation. But, you have to reset in order for it to work.
local Player = game.Players.LocalPlayer
local on = false
local Character = Player.CharacterAdded:Wait()
script.Parent.Equipped:Connect(function()
if Character then
idle = Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent:WaitForChild("Idle"))
idle:Play()
end
end)
script.Parent.Unequipped:Connect(function()
if Character then
idle:Stop()
end
end)
local Player = game.Players.LocalPlayer
local on = false
local Character = Player.CharacterAdded:Wait()
Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
idle = Animator:LoadAnimation(script.Parent:WaitForChild("Idle"))
script.Parent.Equipped:Connect(function()
if Character then
idle:Play()
end
end)
script.Parent.Unequipped:Connect(function()
if Character then
idle:Stop()
end
end)
Your Character variable is only checking for a Player.CharacterAdded event, but no Player.Character as well which is possibly why you need to reset for it to work
local Player = game.Players.LocalPlayer
local on = false
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local idle = Animator:LoadAnimation(script.Parent:WaitForChild("Idle"))
script.Parent.Equipped:Connect(function()
if Character then
idle:Play()
end
end)
script.Parent.Unequipped:Connect(function()
if Character then
idle:Stop()
end
end)