Hello I’m trying to make a Gui Tool Shop.
The issue is Whenever the player resets the Tool is gone.
I tried Cloning in Backpack and StarterGear and it didn’t work.
Here’s the script:
player = script.Parent.Parent.Parent.Parent.Parent
money = player.leaderstats.Cash
price = 100
tool = game.ReplicatedStorage:findFirstChild("Key")
function buy()
if money.Value >= price then
money.Value = money.Value - price
tool:Clone().Parent = player.BackPack
tool:Clone().Parent =player.StarterGear
end
end
script.Parent.MouseButton1Down:connect(buy)
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
local Humanoid = Char:WaitForChild("Humanoid")
Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if (Humanoid.Health <= 0) then
local ToolsFolder = Instance.new("Folder")
ToolsFolder.Parent = game:GetService("ReplicatedStorage")
ToolsFolder.Name = Player.Name
for i,v in pairs(Player.Backpack:GetChildren()) do
if (v:IsA("Tool")) then
v.Parent = ToolsFolder
end
end
for i,v in pairs(Char:GetChildren()) do
if (v:IsA("Tool")) then
v.Parent = ToolsFolder
end
end
Player.CharacterAdded:Wait()
task.wait(0.1)
for i,v in pairs(ToolsFolder:GetChildren()) do
v.Parent = Player.Backpack
end
ToolsFolder:Destroy()
end
end)
end)
end)