Hello, so I have here a LocalScript in StarterCharacter that is a key bind animation. When you click a certain key on your keyboard, and an animation plays and continues to play until you click the key again.
When testing, I found that if a person resets or dies, the script can no longer find the child. The child is an animation named "Anim1" and that is the animation that plays. Here is the script I have currently.
local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local CanEmote = true
local CoolDown = 0
local debounce = false
local dance = hum:LoadAnimation(script:FindFirstChild("Anim1"))
dance.Looped = true
game:GetService("UserInputService").InputBegan:Connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.F then
if debounce == false then
debounce = true
if CanEmote == true then
hum.JumpPower = 0
hum.WalkSpeed = 0
CanEmote = true
dance:Play()
end
elseif debounce == true then
debounce = false
dance:Stop()
hum.WalkSpeed = 16
hum.JumpPower = 50
end
end
end)
Does anyone know how to detect the child that is an animation? I want to understand how to do this, so If you could explain some things that would be great. Any help is appreciated, thank you.

1 comment
When a humanoid dies the character model deletes and all the scripts inside doesnt work. When they respawn the model replictes itsellf like and scripts dont work to fix this just add a while loop