So what I'm making is a game where you sell your deaths for coins but it has been stumping me for awhile I have been questing how to even make the deaths into coins by touching a block so that's why I don't have a script because I don't know how to start it or make it basically what mining sim does but with no backpack but from the leader-board.
First of all you'll need to track Player Deaths.
Players.PlayerAdded:Connect(function(Player) local Leaderstats = Instance.new("Folder") Leaderstats.Name = "leaderstats" local Deaths = Instance.new("IntValue") Deaths.Name = "Deaths" Deaths.Parent = Leaderstats local Money = Instance.new("IntValue") Money.Name = "Money" Money.Parent = Leaderstats Leaderstats.Parent = Player Player.CharacterAdded:Connect(function(Character) Character:WaitForChild("Humanoid").Died:Connect(function() Deaths.Value = Deaths.Value + 1 end) end) end)
The code above creates the Leaderstats folder, Deaths value and Money value in the player which will be displayed on the PlayerList. When the Player dies, their Deaths Value is increased by 1.
Next, we'll need to attach some code to a Part so that when it's touched it'll convert the your Deaths into Money!
local Multiplier = 1 Part.Touched:Connect(function(Hit) local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent) if Player then local Leaderstats = Player.leaderstats Leaderstats.Money.Value = Leaderstats.Money.Value + (Leaderstats.Deaths.Value * Multiplier) Leaderstats.Deaths.Value = 0 end end)
This code will convert your Deaths into Money. Right now you'll get the same amount of Money as your Deaths. You can increase the amount you get by per death by increasing the Multiplier.
Anything less than 1 will give you less Money, anything more than 1 will give you more Money.
so what you mean for the last script is that I get a block then I step on it and it converts my deaths in to coins?