How do I make sure the purchased tool stays within the player's inventory after death?
Asked by
5 years ago Edited 5 years ago
In my previous question, I asked on how I would make sure a tool will always remain in the player's inventory even after death.
The solution someone gave me was to use :WaitForChild('StarterGear')
.
This is my shop script, which is a LocalScript
in an ImageButton
.
01 | script.Parent.MouseEnter:Connect( function () |
02 | game.StarterPlayer.Mouse_hover:Play() |
05 | local canPurchase = false |
07 | script.Parent.MouseButton 1 Click:Connect( function () |
08 | game.StarterPlayer.Select:Play() |
09 | local confirmPurchase = script.Parent.Parent.Parent.ConfirmPurchase:Clone() |
10 | confirmPurchase.Visible = true |
11 | confirmPurchase.Parent = script.Parent.Parent.Parent |
12 | confirmPurchase.Yes.MouseButton 1 Click:Connect( function () |
14 | if game.Players.LocalPlayer:WaitForChild( 'leaderstats' ).Vertigo.Value > = 25000 then |
15 | game.StarterPlayer.SFX_SelectAvailable:Play() |
16 | game.Players.LocalPlayer:WaitForChild( 'leaderstats' ).Vertigo.Value = game.Players.LocalPlayer:WaitForChild( 'leaderstats' ).Vertigo.Value - 10000 |
17 | local itemClone = game.ReplicatedStorage.Guns.Sniper:Clone() |
18 | itemClone.Parent = game.Players.LocalPlayer.Backpack |
19 | local itemClone 2 = game.ReplicatedStorage.Guns.Sniper:Clone() |
20 | itemClone 2. Parent = game.Players.LocalPlayer:WaitForChild( 'StarterGear' ) |
21 | game.ReplicatedStorage.Purchased:FireServer( 25000 ) |
22 | confirmPurchase:remove() |
25 | game.ReplicatedStorage.NotEnoughVertigo:FireServer() |
Terribly sorry if it's hard to read, it's the formatting.
Can anyone help me fix this issue? I've had it for a very long time.
Regards, Sensei.