How can you make it so that when you die you get cash? I have tried doing the car weld way but I decided I want to do it that when you, the player dies you get cash. If you need a look at the game to understand better here.
You would use Humanoid.Died
Humanoid.Died:Connect(function()
Cash.Value += 100
end
-- or this:
if Humanoid.Health <= 0 then
Cash.Value += 100
end
1 Like
I saw you have a “Blender” in your game. You could make a script inside of the part that destroys the cars, so that when it detects a certain part in a car touching it, it executes the script to give the player money. Example:
local touchPart = script.Parent
touchPart.Touched:Connect(function(x)
if x.Name == "CarPart" then
--code to add money
end
end
I could do that but i’d rather have it when the player dies anywhere so the code works anywhere and also wouldnt that actually be better to make it when the player dies instead of the car but I may try your idea I just need to figure out the code for money.
ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local human = character.Humanoid
human.Died:Connect(function()
player.Leaderstats.Cash.Value += 1 -- Change as needed
end)
end)
end)
However though, if the player Resets
their character, they’ll still be given the cash.
2 Likes
you could do a function when the player dies then add the cash to their leaderstats
just like this post right here