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

Holding Tools when dead?

Asked by 10 years ago

I want to make a tool if you die you keep it

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

1 answer

Log in to vote
0
Answered by
Dummiez 360 Moderation Voter
10 years ago

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:

01game.Players.PlayerAdded:connect(function(player)
02local weps = Instance.new("ObjectValue")
03weps.Name = "weaponstats"
04 
05local tool1 = Instance.new("BoolValue")
06tool1.Name = "Rocket"
07tool1.Value = false
08 
09local tool2 = Instance.new("BoolValue")
10tool2.Name = "Bomb"
11tool2.Value = false
12 
13local tool3 = Instance.new("BoolValue")
14tool3.Name = "Sword"
15tool3.Value = false
View all 21 lines...

In the StarterGui as a LocalScript:

01wait()
02local plr = game.Players.LocalPlayer
03local stat = plr.weaponstats
04 
05if stat.Rocket.Value then
06rocket = game.ReplicatedStorage["Rocket"]:Clone()
07rocket.Parent = plr.Backpack
08end
09 
10if stat.Bomb.Value then
11bomb = game.ReplicatedStorage["Bomb"]:Clone()
12bomb.Parent = plr.Backpack
13end
14 
15if stat.Sword.Value then
16sword = game.ReplicatedStorage["Sword"]:Clone()
17sword.Parent = plr.Backpack
18end

Make sure your weapons are stored in the ReplicatedStorage, for LocalScripts to be able to access.

0
Cant i just use Enabled = False? happymoon5 0 — 10y
0
1. game.Players.LocalPlayer.weaponstats. is it local script or normal script??? same for script service happymoon5 0 — 10y
Ad

Answer this question