Hello,
So basically in my game there’s a pad that teleports you to a part located inside a hidden black box under the next location where your character waits for 8 seconds meanwhile the game loads the surroundings. In said time waiting, you’ll see a ScreenGui that says “Loading, please wait,” but despite adding a line to have it removed at the end of the script after 8 seconds it won’t do so. Before I show the setup and such, here’s a clip of what’s going on:
I know the teleportation script works fine as I can hear the music in the background playing meaning you’ve fully loaded into the next location and ready to continue your way. However the ScreenGui doesn’t want to disappear, am I missing something?
The setup:
The invisible pad inside Workspace that teleports you once you get close to the portal:
The code inside “Pad3tpScript” Script (nothing too crazy):
local WaitingPart = game.Workspace.WaitingPart
local LoadingSound = game.Workspace.loading
local ReplicatedStorage = game:GetService("ReplicatedStorage")
script.Parent.Touched:Connect(function(touchPart)
if touchPart and touchPart.Parent and touchPart.Parent.Humanoid and touchPart.Parent.currentlyTeleporting.Value == false then
local Character = touchPart.Parent
local teleportLocation = CFrame.new(WaitingPart.CFrame.X, WaitingPart.CFrame.Y + 5, WaitingPart.CFrame.Z)
local player = game.Players:GetPlayerFromCharacter(touchPart.Parent)
Character:SetPrimaryPartCFrame(teleportLocation)
local teleportingValue = Character.currentlyTeleporting
teleportingValue.Value = true
LoadingSound:Play()
task.wait(8)
teleportingValue.Value = false
end
end)
The code inside the “ShowGUI” Script (pretty simple stuff once again):
local GUI = script.loadingscreen
script.Parent.Touched:connect(function (hit)
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players[hit.Parent.Name]
if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(GUI.Name) then
GUI:Clone().Parent = plr.PlayerGui
task.wait(8)
GUI.Enabled = false
end
end
end)
Here’s the setup for the part you get teleported to to wait for 8 seconds meanwhile your surroundings load in just in case it’s needed to see:
The code inside “Pad4tpScript” (pretty much the first script but with a few things different):
local Pad4 = game.Workspace.Pad4
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GUI = game.Workspace.Pad3.ShowGUI
function onTouched(hit)
hit.Parent.HumanoidRootPart.Anchored = true
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid~=nil then
humanoid.WalkSpeed = 0
task.wait(8)
local Character = hit.Parent
local teleportLocation = CFrame.new(Pad4.CFrame.X, Pad4.CFrame.Y + 5, Pad4.CFrame.Z)
Character:SetPrimaryPartCFrame(teleportLocation)
humanoid.WalkSpeed = 13
end
end
script.Parent.Touched:Connect(onTouched)
I’ve also tried GUI:Destroy()
but not even that seems to get rid of it. I’d appreciate some help on this little issue as it’s the only problem I’m currently experiencing with teleportation to the next area!