Hi! I am currently making an airport game. I was making self check-in, but I ran to this problem.
When I touched it to show the gui for the second time, it couldn’t find the gui in the script and it encountered an error.
* selfcheckin is not a valid member of Script "Workspace.teeji check in.teeji machines pack.Model.Hi.Script" *
This is my script.
Touched :
script.Parent.Touched:connect(function(hit)
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
print(plr)
if plr.PlayerGui:FindFirstChild("selfcheckin") then
print("already has")
else
local toclone = script.selfcheckin
clone = toclone:Clone()
clone.Parent = plr.PlayerGui
end
end
end)
Please help.
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
print(plr)
if plr.PlayerGui:FindFirstChild("selfcheckin") then
print("already has")
else
local toclone = script.selfcheckin
clone = toclone:Clone()
clone.Parent = plr.PlayerGui
end
end
end
end)
do it like this
In your case you are trying to get the player every time your part touches. But your part can touch something other than player, and in that case you are referensing wrong objects.
With my script you are first checking if the touched part has a humanoid in it, and only then getting the player from it
Still didn’t work. It still got the same error
change this with
local toclone = plr.PlayerGui.selfcheckin
That wouldn’t work. When it touches the first time it wouldnt find it.
Oh wait, i dont understand what you are trying to do. By your code you are copying something from under your script to the player. Does your script have a child named “selfcheckin”?
Try doing
local toclone = script:WaitForChild("selfcheckin")
It might be that by the time you are running that script the selfcheckin hasnt loaded in yet.
Is the selfcheckin there from the start or are you instantiating it with another script?
If this doesnt work, put your selfcheckin gui in replicated storage and clone it from there
1 Like
The second solution worked. Thanks!
1 Like