I dont know what this script kinda doesand i kinda need help

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)

that s all.

3 Likes

This seems like garbage ChatGPT code. What were you trying to do?

1 Like

i tried to do a animation after a player died.And no i didn t use chatgpt.
but why did u say i used it?

This code doesn’t look right. did you confuse the usage of tweens with animations?

ohhh probably yes, but can u explain what a tween service really does?

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.

Adding onto Qariter, if you are playing these animations, you need to have made the animations first, with blender or the built in animation plugin.

1 Like

wait what will breakjointsondeath do if there s alredy an event that is the humanoid.Died:Connect() and why is this not being Connected t anything.

it literally “breaks” the rig and parts, which will also “kill” the character.

Oh, you just have to do Humanoid.BreakJointsOnDeath = false after you get the humanoid. My bad for the confusion!

If you’re new to scripting, I seriously recommend looking more on tutorials before tackling this.

Also, I meant make a function using Humanoid.Died!

1 Like

i dont know why i find sometimes tutorials kinda boring can u tell me a scripter that explains like a little better then some others

a youtuber i mean sorry about that

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.

uhh other people already made a tutorial so you can look at that, or you can use youtube.

ohhh like api docs i once saw a video which said to like to look at the devhub and forms instaed of mindlessly looking at docs

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)

i dont wanna just copy and past code tho i actually want to learn the code

alright lil bro

thats up to you if you want to copy paste or actually learn code

I wish you learn all the advanced scripting and become super bilionare with infinite robux :happy3:

thx tho for helping tho. hope u make a really good game one day too :grinning:

1 Like