I want to make a tool if you die you keep it
✓ ANSWER ACCEPTED
Holding Tools when dead?
1 answer
✓ Accepted answer
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.
2 comments
0
Cant i just use Enabled = False?
0
- game.Players.LocalPlayer.weaponstats. is it local script or normal script??? same for script service
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Explain more clearer and I may be able to help.
A tool when you have it, and you die for some reason its still in your inventory
Why don't you put the tool in the Starter-pack ? Easy as.
but if people buy it :/