Teleport script not enabling UI

The teleport works perfectly and I was able to enable the UI when I put the single line of code responsible for it (game.StarterGui.Level2.Enabled = true) in a script by itself. I’m not getting any errors when I do this either, yet the UI still isn’t appearing. Any help would be greatly appreciated!

local Teleport = "Endpoint" -- Destination
local TweenService = game:GetService("TweenService")
local UI = game.StarterGui.Level2.TextLabel

local info = TweenInfo.new(
	5, --Time animating
	Enum.EasingStyle.Sine, --Easing style
	Enum.EasingDirection.Out, --Easing direction in/out/inout
	0, --Repetitions
	false, --Reverse post tween?
	0 --Delay time
)

local goal = {
	TextTransparency = 1;
	TextStrokeTransparency = 1;
}

local fadingtext = TweenService:Create(UI, info, goal)

function Touch(hit)
	if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce
	local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to
		hit.Parent:moveTo(Pos.Position)
		game.StarterGui.Level2.Enabled = true
		wait(3.5) 
		fadingtext:play()
		script.Parent.Locked = false 
		script.Parent.Parent:findFirstChild(Teleport).Locked = false 
	end 
end

script.Parent.Touched:connect(Touch)

Did you check to see if the gui was enabled?

It’s supposed to start off as disabled so that they player doesn’t see it until they hit the teleport

ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

The ui variable isn’t going to the players PlayerGui

local UI = game.Players.LocalPlayer.PlayerGui.Level12.TextLabel

2 Likes

You have to access the Player.PlayerGui instead of game.StarterGui for it to replicate to the player.

2 Likes

Almost forgot, what do I define player as?

StarterGui is what the player is given when they join. When you change it, it doesn’t change what the player sees because it was already given to the player.

PlayerGui is what the player currently sees. That is why when you change the PlayerGui, it changes what the player sees.

2 Likes

How do I fix the error “Workspace.Teleporter.Teleport1.Script:3: attempt to index nil with ‘PlayerGui’” from that?

Here is a script:
(also you shouldn’t mark a post as a solution if you didn’t fix it yet, I also organized your code better)

--//Services
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

--//Variables
local Part = script.Parent

local Info = TweenInfo.new(
	5, 
	Enum.EasingStyle.Sine, 
	Enum.EasingDirection.Out, 
	0, 
	false, 
	0 
)

local Goal = {
	TextTransparency = 1;
	TextStrokeTransparency = 1;
}

--//Functions
Part.Touched:Connect(function(Hit)
	local Player = Players:GetPlayerFromCharacter(Hit.Parent)
	
	if Player and Part.Parent.Locked == false and Part.Parent:FindFirstChild("Waypoint").Locked == false then 
		Part.Locked = true 
		Part.Parent.Waypoint.Locked = true
		
		local Position = Part.Parent.Waypoint.Position 
		Hit.Parent:MoveTo(Position)
		Player.PlayerGui.Level2.Enabled = true
		
		task.wait(3.5) 
		
		local fadingtext = TweenService:Create(Player.PlayerGui.Level2.TextLabel, Info, Goal)
		fadingtext:Play()
		Part.Locked = false 
		Part.Parent.Waypoint.Locked = false 
	end 
end)

(another thing, look at your capitalization)

Got the error “Locked is not a valid member of Model “Workspace.Teleporter””

That’s a problem on your end because I’m assuming that these paths actually lead somewhere. The error is saying that you didn’t add a Locked value to your teleporter so you should go add one.

You can also just send me your teleporter in a model/rbxm file so it’s easier for me to code and put together for you if you can’t do it by yourself.

1 Like

teleporter.rbxm (4.0 KB), I also unmarked the solution

teleporter.rbxm (4.0 KB) Fixed version. I changed the system so it’s easier for you to use later.

1 Like

Tested & verified this works. Thanks for your help and sorry for marking that other post as the solution.

1 Like

No problem, have a good day!

30