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)
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!
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.
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”)
Local script isn’t the script that is supposed to show the GUI.
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)