Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make sure that a player will respawn with gear?

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?

1 answer

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! :)

2 comments

0

Thank you for the help but I figured out the problem that I'm having and it's because I can't add a gear to StarterGear via LocalScript. How do I get around this because the code is in a GUI?

0

You can use a RemoteEvent to tell the server to add it for you. @Michael_TheCreator

This discussion is preserved as it was. New answers, comments, and votes are closed.