-
My script is when I walk through a door it loads a LoadingScreen GUI and teleports me into a Job.
-
The Issue is that I go through the door to my Job then I teleport back to spawn but when I go back through the door it is not reloading my GUI.
(Script TP’s Player to Job) Located in StarterGui.LoadingScreen.Frame V
-- Script for teleporting a player to another part's position upon collision
local teleportPart = game.Workspace.touchedPart -- Assuming this script is a child of the teleporting part
local destinationPart = game.Workspace:WaitForChild("endPart") -- Replace with the name of the destination part
local function onTouched(other)
local character = other.Parent
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
-- If touched by a player's humanoid, teleport the player to the destination part
if humanoid then
local gui = script.Parent
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local tween = game:GetService("TweenService"):Create(gui, tweenInfo, {BackgroundTransparency = 0})
gui.Visible = true
tween:Play()
wait(2)
character.HumanoidRootPart.CFrame = destinationPart.CFrame
gui.Parent.Parent.FactoryGUI.Enabled = true
gui.Parent.Parent.FactoryGUI.ParentFrame.Visible = true
gui.Parent.Parent.VHs.Enabled= true
wait(0.25)
local tweenInfo2 = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local tween2 = game:GetService("TweenService"):Create(gui, tweenInfo2, {BackgroundTransparency = 1})
tween2:Play()
wait(1.5)
gui.Visible = false
end
end
-- Connect the 'Touched' event of the teleport part to the 'onTouched' function
teleportPart.Touched:Connect(onTouched)
(Script TP’s Player Back) Located in StarterGui.FactoryGUI.ParentFrame.MainFrame.StartShift.startButton
local button = script.Parent
button.MouseButton1Click:Connect(function()
local parentFrame = button:FindFirstAncestorWhichIsA("ScreenGui").ParentFrame
local viewedStats = button:FindFirstAncestorWhichIsA("ScreenGui").ViewShift.viewedstats
parentFrame.Visible = false
viewedStats.Visible = true
end)