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

How to open gui shop and teleport player when part is stepped on?

So, I want to make it so that when you step on a part a gui shop opens for you, and just for you. But when I put it in a local script, I can't make the stepped on part, and when I put it in a normal script, it opens the gui for everyone, and I don't know how to work around that. I also don't know how I can teleport the player to specific coords. Help appreciated.

1 answer

For whatever part you are touching add a script like this:

local Part = script.Parent

part.Touched:Connect(function(player)
	player.EDIT this to your gui opening
end)

I used to be confused by this too, the answer is simple though. By adding player in the function parenthesis you are adding a variable for whatever touches the part, a genius move by roblox if I say so myself. However, you will quickly notice that errors will pop up in the output tab but the script still works as it should. To get around this you need to have an if statement that asks if the variable player is actually a player, like this:

local Part = script.Parent

part.Touched:Connect(function(player)

	if player.Parent:FindFirstChild('Humanoid') then
		player.Edit This to Your Gui Opening
	end

end)

Any more questions? Just Comment!

-- WolfTamer894

3 comments

0

for the edit this to your gui opening do i just change that text to the name of my gui? or do i go like game.Workspace.ScreenGui?

0

sorry i coded that bad i did it in like 3 seconds lol

0

Do it like Game.Players.Localplayer. and this is where you type the name of your gui such as "Menu"

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