Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

A Script where it takes a players cash and gives it to another player when the player is dead?

Asked by
4d0z 4
4 years ago

Exactly what the title says. I'll elaborate more. Let's say I kill a player with 100 points. when the player is killed, it resets the dead player's points to zero and you get all of the player's points.

Here's what I have so far.


game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player -- Display an 'IntValue' on leaderboard local Power = Instance.new("IntValue") Power.Name = "Power" Power.Value = 150 Power.Parent = leaderstats player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() local tag = character.Humanoid:FindFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then Power.Value = Power.Value +10 end end end) end) end)
0
thats cruel TheluaBanana 946 — 4y
0
i know ;) 4d0z 4 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

most game just spawn lots of "points" on the ground when one player die, and another player just walk through the points and collect all of them. I think that is the easiest way.

The script above is another way, the hard way. you only have half of the script. you are missing the other half. When a sword or a bullet touch something, it needs to find out whether it is a stand alone object, or whether it is part of humanoid. if it is part of humanoid, where is the tag. it can go scarf -> helmet -> head -> character, then go down again, character -> humanoid, create a tag in this level.

after the 2nd part of the script, your above part of script will work

0
What? 4d0z 4 — 4y
Ad

Answer this question