Script should insert a stringvalue into players torso after player dies. I've coded a ragdoll which will make body stay for a while and i need a ragdoll to have stringvalue inside it
✓ ANSWER ACCEPTED
How to make script insert a stringvalue into player after death?
3 answers
✓ Accepted answer
This can be easily achieved by humanoid.Died or humanoid.HealthChanged. Here is the examples:
Humanoid.Died:Connect(function()
local StringValue = Instance.new("StringValue", game.Players.LocalPlayer)
end)
Remember that these can only work on a local script! (Both examples use Instance.new, don't forget that too)
Humanoid.HealthChanged:Connect(function(health)
if health == 0 then
local StringValue = Instance.new("StringValue", game.Players.LocalPlayer)
end
end)
That is basically it
Extra (On server)
local plrs = game.Players
plrs.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Humanoid = character:WaitForChild("Humanoid")
if player and humanoid then
Humanoid.Died:Connect(function()
local StringValue = Instance.new("StringValue", player)
end)
end
end)
end)
That is basically it! Thanks for reading this even if you did, hope this helps on putting a value in a player when they die.
You can use Instance.new() and Humanoid.Died. These links may be useful:
in startercharacterscripts:
script.Parent.Humanoid.Died:Connect(function()
game.ReplicatedStorage.stringValue:Clone().Parent = script.Parent
end)
put the string value that needs to cloned into rep storage then when they die this will clone it in.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you so much man!