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:

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.

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