This script basically places the 'TeleportGUI' in the player when they touch the block, as long as they dont already have one in them. This always works the first time around, but never again. Is there a flaw?
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
user = game.Players:findFirstChild(human.Parent.Name)
if not player.PlayerGui:FindFirstChild("TeleportGUI") then
script.Parent.TeleportGUI:clone().Parent = player.PlayerGui
end
wait(2)
else
wait(2)
debounce = false
end
end
Also, the TeleportGUI gets destroyed after the player uses it. Heres the script in the TeleportGUI
function Click()
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local HRP = Character.HumanoidRootPart
HRP.CFrame = CFrame.new(workspace.forestbrick.Position)
Player.leaderstats.Attempts.Value = 0
script.Parent.Parent.Parent:Destroy()
end
script.Parent.MouseButton1Down:connect(Click)

3 comments
please indent your code
there you go
Well i am sorry that i cant answer your question but you have a Secruity issue a hacker could insert a local script that give them the power to open/copy the GUI on their command