im trying to make an elevator that when a player goes inside they will wait the cooldown. when the cooldown ends that player and anyone else inside elavator teleports to main game. i hope i was able to explain enough in the script’
local teleportToGame = script.Parent.Parent:WaitForChild("Part") -- Part that covers entire elevator and will be used to tell if a player is touching it so if they decide to leave it doesnt tp them
local leaving = script.Parent.Parent:WaitForChild("Leaving") -- part with surface gui inside
local SurfaceGui = leaving.SurfaceGui:WaitForChild("TextLabel") -- the text label inside the surface gui
local debounce = false
script.Parent.Touched:Connect(function(hit) --script.parent is the part they touch to tp inside the elevator (its located on the outside)
if debounce then
return
end
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-11, 3, -140.373) --the middle part of the elevator
warn("Teleported")
game.StarterGui.Playergui.Leave.Visible = true --the text button that gives them option to leave (im planning on using replicated storage later)
debounce = true
SurfaceGui.Text = "Leaving In: 30" --sorry im not good with loops :(
wait(1)
SurfaceGui.Text = "Leaving In: 29"
wait(1)
SurfaceGui.Text = "Leaving In: 28"
wait(1)
SurfaceGui.Text = "Leaving In: 27"
wait(1)
SurfaceGui.Text = "Leaving In: 26"
wait(1)
SurfaceGui.Text = "Leaving In: 25"
wait(1)
SurfaceGui.Text = "Leaving In: 24"
wait(1)
SurfaceGui.Text = "Leaving In: 23"
wait(1)
SurfaceGui.Text = "Leaving In: 22"
wait(1)
SurfaceGui.Text = "Leaving In: 21"
wait(1)
SurfaceGui.Text = "Leaving In: 20"
wait(1)
SurfaceGui.Text = "Leaving In: 19"
wait(1)
SurfaceGui.Text = "Leaving In: 18"
wait(1)
SurfaceGui.Text = "Leaving In: 17"
wait(1)
SurfaceGui.Text = "Leaving In: 16"
wait(1)
SurfaceGui.Text = "Leaving In: 15"
wait(1)
SurfaceGui.Text = "Leaving In: 14"
wait(1)
SurfaceGui.Text = "Leaving In: 13"
wait(1)
SurfaceGui.Text = "Leaving In: 12"
wait(1)
SurfaceGui.Text = "Leaving In: 11"
wait(1)
SurfaceGui.Text = "Leaving In: 10"
wait(1)
SurfaceGui.Text = "Leaving In: 9"
wait(1)
SurfaceGui.Text = "Leaving In: 8"
wait(1)
SurfaceGui.Text = "Leaving In: 7"
wait(1)
SurfaceGui.Text = "Leaving In: 6"
wait(1)
SurfaceGui.Text = "Leaving In: 5"
wait(1)
SurfaceGui.Text = "Leaving In: 4"
wait(1)
SurfaceGui.Text = "Leaving In: 3"
wait(1)
SurfaceGui.Text = "Leaving In: 2"
wait(1)
SurfaceGui.Text = "Leaving In: 1"
wait(1)
SurfaceGui.Text = "Loading..."
wait(1)
SurfaceGui.Text = "Loading.."
wait(1)
SurfaceGui.Text = "Loading."
wait(1)
SurfaceGui.Text = "Loading..."--fake loading screen
wait(1)
teleportToGame.Touched:Connect(function(hit) --after the loading ends make the part covering inside elevator tp anyone ttouching it
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-460.4, 6, -6.3) --position of game
warn("TeleportedToGame")
else
warn("ERROR") --if all else goes wronge
end
end)
end
end)
if the script isnt enough access this model:
you will have to get rid of the part where i make the leave button visible though.
side note if anyone wants to work on game with my ill be happy to accept you <3
edit: im just sitting in an elevator and the tp isnt teleporting me to game when load ends (the issue is at end of script near when i teleport player to game
When you’re talking about teleporting to the game do you mean as in a position thing like a minigame within the same experience? Or do you mean like a camping game teleport that’s transfer you into a different experience?
ah i rescripted the whole thing then u found the solution
oh well here it is anyways, might not be the best way to approach it and also might not even work but here
local teleportToGame = script.Parent.Parent:WaitForChild("Part")
local leaving = script.Parent.Parent:WaitForChild("Leaving")
local SurfaceGui = leaving.SurfaceGui:WaitForChild("TextLabel")
local debounce = false
local Timer = 30
local IsLoaded = false
script.Parent.Touched:Connect(function(hit)
if debounce == false then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:MoveTo(-11, 3, -140.373)
print("Teleported")
game.StarterGui.Playergui.Leave.Visible = true
debounce = true
while task.wait(1) do
if Timer <= 30 and Timer >= 1 then
Timer -= 1
SurfaceGui.Text = "Leaving in: " .. Timer
elseif Timer < 1 then
SurfaceGui.Text = "Loading..."
wait(3)
IsLoaded = true
end
end
end
end
end)
teleportToGame.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and IsLoaded == true then
hit.Parent:MoveTo(-460.4, 6, -6.3) --position of game
print("TeleportedToGame")
end
end)
local teleportToGame = script.Parent.Parent:WaitForChild("Part")
local leaving = script.Parent.Parent:WaitForChild("Leaving")
local SurfaceGui = leaving.SurfaceGui:WaitForChild("TextLabel")
local debounce = false
local Timer = 30
local IsLoaded = false
script.Parent.Touched:Connect(function(hit)
if debounce == false then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:MoveTo(Vector3.new(-11, 3, -140))
print("Teleported")
game.StarterGui.Playergui.Leave.Visible = true
debounce = true
while task.wait(1) do
if Timer <= 30 and Timer >= 1 then
Timer -= 1
SurfaceGui.Text = "Leaving in: " .. Timer
elseif Timer < 1 then
SurfaceGui.Text = "Loading..."
wait(3)
IsLoaded = true
end
end
end
end
end)
teleportToGame.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and IsLoaded == true then
hit.Parent:MoveTo(Vector3.new(-460, 6, -6)) --position of game
print("TeleportedToGame")
end
end)
while task.wait(1) and IsLoaded == false do
if Timer <= 30 and Timer >= 1 then
Timer -= 1
SurfaceGui.Text = "Leaving in: " .. Timer
elseif Timer < 1 then
SurfaceGui.Text = "Loading..."
wait(3)
IsLoaded = true
end
end
or also:
while task.wait(1) do
if Timer <= 30 and Timer >= 1 then
Timer -= 1
SurfaceGui.Text = "Leaving in: " .. Timer
elseif Timer < 1 then
SurfaceGui.Text = "Loading..."
wait(3)
IsLoaded = true
return
end
end