Stuck on changing GUI variable value from Client OnTouch Event

Hi all, I am trying to make a tutorial GUI that runs on local scripts to bring up a part in the workspace and when touched, changes a value in the gui.
I haven’t experimented with onTouch events through GUI before so I am lost to what the problem could be, if I am even doing it right to begin with. In the ouput i get “WayPoint1 is not a valid member of Workspace “Workspace” - Client - LocalScript:2”
The script is inside a ScreenGUI along with a bool variable. The Main script that runs the GUI goes into a wait loop until said variable becomes true when a part is touched then it continues to the rest of the tutorial. This script below is to change that variable’s value.
What am I missing?

local Point1 = workspace.WayPoint1
local Point2 = workspace.WayPoint2 
local Point3 = workspace.WayPoint3 
local Player = game.Players.LocalPlayer

Point1.Touched:Connect(function(PartTouched) 
	if PartTouched.Parent.Name == Player.Name then -- If the players name = the player then it destorys the part on his client and not others
		script.Parent.waitval.Value = true
	
	end
end)
Point2.Touched:Connect(function(PartTouched) 
	if PartTouched.Parent.Name == Player.Name then -- If the players name = the player then it destorys the part on his client and not others
		script.Parent.waitval.Value = true

	end
end)
Point3.Touched:Connect(function(PartTouched) 
	if PartTouched.Parent.Name == Player.Name then -- If the players name = the player then it destorys the part on his client and not others
		script.Parent.waitval.Value = true

	end
end)

The error means that WayPoint1 isn’t in the workspace yet - as far as the client is concerned.

To remedy this:

  • Ensure that it does actually exist in the workspace
  • Do workspace:WaitForChild("WayPoint1") instead of workspace.WayPoint1.
1 Like

omg that worked, thank you so much :sweat_smile: Now I know for next time what to do when I implement my tutorial into other games.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.