script.Parent.MouseButton1Click:connect(function() local RS = game:GetService("ReplicatedStorage") local item = RS:WaitForChild("Firebrand") local price = 25 local player = game.Players.LocalPlayer local stats = player:WaitForChild("leaderstats")
if stats.Souls.Value>=price then stats.Souls.Value = stats.Souls.Value - price local cloned = item:Clone() cloned.Parent = player.Backpack cloned.Parent = player.StarterGear end
I am looking forward to somebody's response.
Thank you, Sqookly
well, starter pack is not inserted into a player when the game starts; instead, a new folder named "Backpack" is made and inserted into the player to hold all the equipable tools;
so lets say i have a tool in starterpack named "gun"
to access it; i would have to do: player.Backpack.gun
You could create a StarterGear if it doesn't exist. Just check if it exists and if it doesn't, make a new one.
local StarterGear = Player:FindFirstChildOfClass('StarterGear') if (not StarterGear) then StarterGear = Instance.new('StarterGear', Player) end
More effort, but will solve your problem and can be more reliable (like if you want to put the tools in a certain order).
Just save the player's tools using a dictionary or some other method and clone it when they spawn in.
--saving tools as starter local savedTools = {} savedTools[Player] = {Item1, Item2, Item3} --spawning tools Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local tools = savedTools[player] for i, tool in pairs(tools) do --clone in backpack end end) end)
script.Parent.MouseButton1Click:connect(function() local RS = game:GetService("ReplicatedStorage") local item = RS:WaitForChild("Firebrand") local price = 25 local player = game.Players.LocalPlayer local stats = player:WaitForChild("leaderstats") local SG = player:WaitForChild("StarterGear") or player:FindFirstChild("StarterGear") -- when u do FindFirstChild u can do --< if SG then --code here else SG = player:WaitForChild("StarterGear") -- try to find it again --other code to start over on the if SG then -- end > if stats.Souls.Value>=price then stats.Souls.Value = stats.Souls.Value - price local cloned = item:Clone() cloned.Parent = player.Backpack cloned.Parent = SG end end)