I have tried something the internet said that the tool should be cloned to the starterPack but it still doesnt work and now i have no clue what i shall do did i miss something
01 | local price = 3 -- The price of your item. |
02 | local price 2 = 2 |
03 | local price 3 = 1 |
04 | local db = true |
05 |
06 | script.Parent.ClickDetector.MouseClick:connect( function (player) |
07 | if player.leaderstats.Wood.Value > = price |
08 | and player.leaderstats.Sticks.Value > = price 2 |
09 | and player.leaderstats.String.Value > = price 3 then |
10 | player.leaderstats.Wood.Value = player.leaderstats.Wood.Value - price |
11 | player.leaderstats.Sticks.Value = player.leaderstats.Sticks.Value - price 2 |
12 | player.leaderstats.String.Value = player.leaderstats.String.Value - price 3 |
13 |
14 | db = false |
15 | script.Parent.BrickColor = BrickColor.new( "Bright red" ) |
16 | game.ReplicatedStorage.WoodPickaxe:Clone().Parent = player.StarterPack |
17 | wait( 0.5 ) |
18 | script.Parent.BrickColor = BrickColor.new( "Bright green" ) |
19 | db = true |
20 | end |
Yes, you can clone the tools to the player's StarterPack after death. It would look something like this:
1 | player.Character.Humanoid.Died:Connect( function () |
2 | player.StarterPack:ClearAllChildren() |
3 | for _,tool in pairs (player.Backpack:GetChildren()) do |
4 | tool:Clone().Parent = player.StarterPack |
5 | end |
6 | end ) |
If this does not work for you, what about it is not working? Are there any errors?
EDIT
To address your latest comment, when I said "You will need to have a reference to the player object and make sure the character is not nil too", I meant it.
If you are going to copy and paste the code I provide into an empty script, you will need to do something like this:
01 | game.Players.PlayerAdded:Connect( function (player) -- a reference to the player is added here |
02 | player.CharacterAdded:Connect( function (char) -- making sure a character has been assigned to the player |
03 | char.Humanoid.Died:Connect( function () -- checking for player death |
04 | player.StarterPack:ClearAllChildren() |
05 | for _,tool in pairs (player.Backpack:GetChildren()) do |
06 | tool:Clone().Parent = player.StarterPack |
07 | end |
08 | end ) |
09 | end ) |
10 | end ) |