How could I make a teleport gui

Hello, I am struggling to find a resource for this idea, and I think I have to make my own

  1. What do you want to achieve? I want to have a gui that teleports you somewhere, and reappears every 3 minutes, not since you clicked it, but every 5 mniutes, it also has to disappear after you click it

  2. What is the issue? I get an error that the part isnt in workspace, but it is, and, I dont have the reappear aspect in the script

  3. What solutions have you tried so far? I looked in roblox studio for free models, I couldnt find anything

local part = workspace.TeleportPart -- Name of my part
local plr = game.Players.LocalPlayer



script.Parent.MouseButton1Click:Connect(function()
    local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
     if humanoidrootpart then
        humanoidrootpart.CFrame = CFrame.new(part.CFrame.p) + Vector3.new(0,5,0)
    end
end)

thanks

3 Likes

First of all you said: CFrame.new(part.CFrame.p) Which CFrame.p means getting the position. Which you don’t need just say:

local part = workspace.TeleportPart -- Name of my part
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
    local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
     if humanoidrootpart then
          humanoidrootpart.CFrame = part.CFrame + Vector3.new(0,5,0)
    end
end)

Also, how I would do it is make a serversided debounce (cooldown) and instead of doing this all in a local script just fire to the server. Then, check if their debounce (cooldown) timer is up and if it is teleport them.

You will also update the timer on the server using a loop that runs every second.

How would we know when to show the Ui?

We can locally check the time to make the Ui visible or not. Which can be done using a loop.

Hope this helped. If you need help writing the code let me know.

humanoidrootpart.CFrame = part.CFrame * CFrame.new(0, 5, 0)

1 Like

I still keep getting the error

teleportpart is not a valid member of workspace “workspace”

1 Like

Maybe the script is loading faster than the block is loading in?

local part = workspace:WaitForChild("TeleportPart") -- Name of my part
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
    local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
     if humanoidrootpart then
          humanoidrootpart.CFrame = part.CFrame + Vector3.new(0,5,0)
    end
end)

it does work now, thanks

question, for noobs like me,

a for loop?

I would use a while loop something like this

while task.wait(1) do 

end

for loops are meant for only a certain number of runs. Also, to loop through arrays.

2 Likes