Hello Developers!
As the title says, whenever I respawn with the tool, it’s equip and idle animation seems to not play for whatever reason.
Notes
- The script is a local script.
- If your wondering why the “OnUse” event is going to be called within the local script is because I want the item to go on cooldown after being used.
local ChickenLeg = script.Parent
--//Anims
local EquipAnim = ChickenLeg:WaitForChild("Equip")
local IdleAnim = ChickenLeg:WaitForChild("Idle")
--//Char
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
--//Functionality
local OnUseEvent = ChickenLeg:WaitForChild("OnUseEvent")
local OnUse = false
ChickenLeg.Equipped:Connect(function()
local EquipAnimTrack = Humanoid:WaitForChild("Animator"):LoadAnimation(EquipAnim)
EquipAnimTrack:Play()
task.wait(0.22)
local IdleAnimTrack = Humanoid:WaitForChild("Animator"):LoadAnimation(IdleAnim)
IdleAnimTrack:Play()
ChickenLeg.Unequipped:Connect(function()
IdleAnimTrack:Stop()
end)
end)
ChickenLeg.Activated:Connect(function()
if not OnUse then
OnUse = true
local StarterGUI = game:GetService("StarterGui")
StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
OnUseEvent:FireServer()
end
end)
OnUseEvent.OnClientEvent:Connect(function()
local StarterGUI = game:GetService("StarterGui")
StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
task.wait(7)
OnUse = false
end)