in my game I have a script inside a part and when you stand on it it teleports you to a specific coordinate and I'm wondering if there is a way to make a gui/ loading screen that shows up for a few seconds when you teleport here is the script that is inside the teleport pad:
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(326.84, 1.57, 245.642) end end)
if someone knows how i could make either an animated loading screen or a gui that pops up for a few seconds when you touch the teleport pad that would be greatly appreciated.
I can help you. In the player there is the PlayerGui
folder which retains all the GUIs available on the player's screen. You can put a GUI in the StarterGui
folder called TeleportationGui
or something like this. Put a frame in that gui and call it TeleportationFrame
and add a text in the middle of the frame which writes on "Teleporting...", or what you want. Have you noticed the Visible
and Active
properties of the frame before? These will help you.
local secondsNumber = 5 local function GetPlayerFromCharacter(character) local players = game.Players:GetChildren() local player for i = 1, #players do if character.Name = players[i].Name then player = players[i] break end end return player end script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(326.84, 1.57, 245.642) local Player = GetPlayerFromCharacter(hit.Parent) if Player then Player.PlayerGui.TeleportationGui.TeleportationFrame.Visible = true Player.PlayerGui.TeleportationGui.TeleportationFrame.Active = true wait(secondsNumber) Player.PlayerGui.TeleportationGui.TeleportationFrame.Visible = false Player.PlayerGui.TeleportationGui.TeleportationFrame.Active = false end end end)
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(326.84, 1.57, 245.642) local screengui = Instance.new("ScreenGui") screengui.Parent = game:GetService("Players")[hit.Parent.Name].PlayerGui local frame = Instance.new("Frame") frame.Parent = screengui frame.Size = UDim2.new(1, 0, 1, 36) frame.Position = UDim2.new(0, 0, 0, -36) frame.BackgroundTransparency = 1 --build the gui here wait(1) --set to how long you want to wait screengui:Destroy() end end)