How can I make it so if someone buys a weapon using In game currency at my dialog shop that if they die they keep it? Could this script part below work if I add the locals and such? Also is this part correct as a body of the script ( I will declare the locals and more ) if Player.Health = 0 then Weapon1.ReplicatedStorage.Clone() Well I could use some tips to make this script work. Thank you.
✓ ANSWER ACCEPTED
Would this work? (Cloning weapons once Player dies script)
2 answers
✓ Accepted answer
insert a script and put in workspace, when you die, you will respawn with your tools
function saveWeapons(player)
local bin = Instance.new("HopperBin")
bin.Parent = game.Lighting
bin.Name = player.Name
local stuff = player.Backpack:GetChildren()
for i = 1,#stuff do
local name = stuff[i].Name
if game.StarterPack:findFirstChild(name)==nil then
stuff[i]:Clone().Parent = bin
end
end
local char = player.Character:GetChildren()
for i = 1,#char do
if char[i].className == "Tool" then
local name = char[i].Name
if game.StarterPack:findFirstChild(name)==nil then
char[i]:Clone().Parent = bin
end
end
end
end
function onRespawned(player)
local findBin = game.Lighting:findFirstChild(player.Name)
if findBin~=nil then
local stuff = findBin:GetChildren()
for i = 1,#stuff do
stuff[i]:Clone().Parent = player.Backpack
end
findBin:Remove()
end
player.Character.Humanoid.Died:connect(function()
saveWeapons(player)
end)
end
function onPlayerEntered(newPlayer)
newPlayer.Changed:connect(function (property)
if (property == "Character") then
onRespawned(newPlayer)
end
end)
while true do
if newPlayer.Character~=nil then break end
wait()
end
newPlayer.Character.Humanoid.Died:connect(function()
saveWeapons(newPlayer)
end)
end
game.Players.PlayerAdded:connect(onPlayerEntered)
Place the gear into the Player's StarterGear and into their Backpack when they purchase the gear. After that, they will spawn with the gear every time until they leave.
2 comments
0
Like clone it into their StarterGui?
0
No, clone it into the Player's Backpack when they first buy it, and also clone it into the Player's StarterGear when they first buy it. They will then spawn with that gear every time.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thanks!
My only problem is that my game has a lobby and I don't want people killing in the lobby.