I’ve made an animation script that would play an animation when a player says a phrase but if they reset the script no longer works. I’m not sure how to make it work when the player does reset so that’s what I need help with.
game:GetService("Players").PlayerAdded:Connect(function(Player)
local character = Player.Character
repeat wait()
character = Player.Character
until character
local Humanoid = character:WaitForChild("Humanoid")
local HRP = character:FindFirstChild("HumanoidRootPart")
local LevitateAnimation = Humanoid:LoadAnimation(LevitateSit)
local LevClone = LevitateSound:Clone()
LevClone.Parent = HRP
LevClone.Looped = true
Player.Chatted:Connect(function(Message)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
if Message == "/e LevitateSit" then
LevClone:Play()
LevitateAnimation:Play()
end
Humanoid.Jumping:Connect(function()
LevClone:Pause()
LevitateAnimation:Stop()
end)
Humanoid.Running:Connect(function()
LevClone:Pause()
LevitateAnimation:Stop()
end)
end
end)
end)