Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

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? dylindude 64 — 3y
0
sorry i coded that bad i did it in like 3 seconds lol dylindude 64 — 3y
0
Do it like Game.Players.Localplayer. and this is where you type the name of your gui such as "Menu" wolftamer894 50 — 3y
Ad

Answer this question