I want to make a tool if you die you keep it
You could have a script similar to leaderstats, but for weapons instead. Use Data Persistence or Data store to save weapons.
When they buy a weapon, make sure to set the player's weapon of selection to true in the weaponstats.
If they buy a rocket, then something like this would be needed:
game.Players.LocalPlayer.weaponstats.Rocket.Value = true
In the ServerScriptService:
game.Players.PlayerAdded:connect(function(player) local weps = Instance.new("ObjectValue") weps.Name = "weaponstats" local tool1 = Instance.new("BoolValue") tool1.Name = "Rocket" tool1.Value = false local tool2 = Instance.new("BoolValue") tool2.Name = "Bomb" tool2.Value = false local tool3 = Instance.new("BoolValue") tool3.Name = "Sword" tool3.Value = false tool1.Parent = weps tool2.Parent = weps tool3.Parent = weps weps.Parent = player end)
In the StarterGui as a LocalScript:
wait() local plr = game.Players.LocalPlayer local stat = plr.weaponstats if stat.Rocket.Value then rocket = game.ReplicatedStorage["Rocket"]:Clone() rocket.Parent = plr.Backpack end if stat.Bomb.Value then bomb = game.ReplicatedStorage["Bomb"]:Clone() bomb.Parent = plr.Backpack end if stat.Sword.Value then sword = game.ReplicatedStorage["Sword"]:Clone() sword.Parent = plr.Backpack end
Make sure your weapons are stored in the ReplicatedStorage, for LocalScripts to be able to access.