Hey, so I'm trying to figure out when I step on this brick, it gives me a GUI, and inside this GUI has a button that can teleport me to a certain place on the map. It doesn't seem to work, and I'm pretty frustrated lol, if anyone can help that would be awesome!
local plr = game.Players.LocalPlayer
local pos1 = game.pos1
function Click()
script.Parent.Parent.Parent.Parent = pos1 --This is probably totally wrong but if they click on it, they get teleported lol.
end
if Click() then
plr.ScreenGUI:remove() -- idk if this is right but if they click on it, it removes the GUI.
end
script.Parent.MouseButton1Down:connect(Click)
--BELOW IS WHEN THEY STEP ON THE PART THE GAME INSERTS THE GUI.
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent:clone().Parent = player.PlayerGui
wait(2)
debounce = false
end
end
script.Parent.Parent.Touched:connect(onTouch)
--This whole script is inserted into the ScreenGUI.
I'm not a great scripter but hopefully I can learn from all of you! (:
Thanks, LukeGabrieI

5 comments
How would I add text to the button through the script?
You would have to put another line after "local button=Instance.new..." that says "button.Text="TEXT""
How would I move the button to a certain place on the screen? lol, sorry for asking a lot!
nvm i got it
I'm okay with questions, no matter how many you ask.