I'm making a shop that allows you to buy gear but when the player resets the gear they bought is no longer there. How can I stop this from happening and how can I make sure that they spawn with the gear?
a.Parent = player.Backpack a.Parent = player.StarterGear
This part of my code seems to be the issue but I'm not sure why?
Hey!
Looks like you're on the right track so far. If you want to have somebody spawn with a tool, you can just add the tool to said players' starter gear by parenting it. An example is shown below...
local tool = game.ServerStorage.Tool -- just an example tool; dont use this exact code lol tool:Clone().Parent = player.StarterGear
If this isn't enough for you and you want to do more before giving the tool, you can give it to them when they spawn with the CharacterAdded
event. This will fire off whenever, well, the character is added. I'll show a code example for that below as well.
local Players = game:GetService("Players") Players.PlayerAdded:Connect (function(plr) -- This will get called whenever a new player joins. plr.CharacterAdded:Connect (function(character) -- Add our CharacterAdded listener local tool = game.ServerStorage.Tool tool:Clone().Parent = player.Backpack -- Parent it to the backpack this time. end) end)
If you have any additional questions, feel free to ask.
If this answer helped, please remember to accept it! :)