GUI not showing up when I touch a part

I made a script that when I touch a part it is supposed to show a GUI. I checked the console in-game and I only get errors when someone else is in the game. I’m very confused and need help!

Script:

local TeleporterPart = game.Workspace.Teleporter.TeleporterPart

TeleporterPart.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr.PlayerGui.TeleporterGUI.Frame.Visible = true
	end
end)

TeleporterPart.TouchEnded:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr.PlayerGui.TeleporterGUI.Frame.Visible = false
	end
end) 

Console errors:

https://gyazo.com/4dae51e55bad831cf40ce7e6c4cfdfa4

Note: I wasn’t touching the part that shows the GUI, but my name is in the errors for some reason :man_shrugging:

Please help! I’m very new to scripting!

Also, when I step on the part by myself, I get no errors. If someone joins and steps on it, I get their errors, and they get my errors. Sorry if it sounds confusing, I’m confused myself. I really need help! :frowning:

try plr:WaitForChild(“PlayerGui”)

Okay, I’ll try that now. I’ll tell you if there are any errors.

also, is this in a local script or a normal script?

It is in a local script I believe.

try with a normal script, see if that does anything

This should be in a server script under the part, and use :WaitForChild(“PlayerGui”) (if you keep on getting the error)

Still does not work sadly. eee

Is the name of your “Teleport” code “FireScript”? Cause if not… it looks like you have something called FireScript causing those errors in your game, and the source is not the code you pasted in your original post.
image

Where would I put that? I’m new to scripting.

Okay,

PUT THIS INSIDE THE PART, SERVER SCRIPT

script.Parent.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr:WaitForChild("PlayerGui").TeleporterGUI.Frame.Visible = true
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr:WaitForChild("PlayerGui").TeleporterGUI.Frame.Visible = false
	end
end) 
local TeleporterPart = script.Parent -- Put inside part

TeleporterPart.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr.PlayerGui.TeleporterGUI.Frame.Visible = true
	end
end)

TeleporterPart.TouchEnded:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr.PlayerGui.TeleporterGUI.Frame.Visible = false
	end
end) 

PlayerGui should be loaded on the server already, but if you’re still receiving the error, replace plr.PlayerGui with plr:WaitForChild(“PlayerGui”)

I just tried that, using a server script. Didn’t work.

well it should, u probably messed something up, do u get anything in the output?

cause i tried it myself on my game and it worked wonders

Nothing in the output at all…

show the code and the path for the code and also the gui path

Screen Shot 2021-02-21 at 6.24.13 PM

Local script isn’t the script that is supposed to show the GUI.

Screen Shot 2021-02-21 at 6.24.32 PM

That script is supposed to make the GUI show.

Code:

script.Parent.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr:WaitForChild("PlayerGui").TeleporterGUI.Frame.Visible = true
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr:WaitForChild("PlayerGui").TeleporterGUI.Frame.Visible = false
	end
end)

what is the script inside the frame used for