hey devs, i am trying to make a cript that when a player dies it does a animation rigth after here is the code:
local plr = game.Parent
local TweenService = game:GetService(“TweenService”)
function plranimation(animation)
local Parent = game:FindFirstChild(“plr”)
plr:Connect(plranimation)
local plr = game.Players.GetPlayerFromCharacter:Connect(“plr”)
if plr.Parent.Hum < 0 then
print(“player has died”)
end
end
plr(TweenService, plranimation())
local plranimation = “” while true do
plranimation() if plr.Parent.Humanoid < 0 then
end
end
Can anyone expain to me what this script kinda does and what i might be doing wrong?(to be honest i am a beginner scripter so yeah i dont know a lot)
You need to get the player’s humanoid, load the animation for it using Humanoid:LoadAnimation() and use Humanoid.Died:Connect() to detect when they die. After they die, anchor their HumanoidRootPart, turn breakjointsondeath off and play the animation.
Said scripter is you. If you don’t have the courage to look at documentation, you’ll have a tougher time learning. You can also try looking at simple freemodel’s scripts, like a killbrick and such.
oh my god let me spoon feed you with some code here
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid=char:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
--player died do something here
end)
end)
end)