ScreenGui : Problems related to scripting

Simple script, however it has a error in the output that not permits me from acessing it!
This is a script that opens a screengui.

LocalScript:

local Player = game:GetService("Players").LocalPlayer
local Gui = script.Parent

local teamColors = {
	BrickColor.new("White")
}

local Screen = workspace.Map.CCI.SCW.Decoration.ControlLockdown:FindFirstChild("ScreenPanel")
local Button = Screen:WaitForChild("SurfaceGui").TextButton

Button.MouseButton1Click:Connect(function()
	for _, Color in pairs(teamColors) do
		if Player.TeamColor == Color then
			local Character = Player.Character
			local Humanoid = Character:WaitForChild("Humanoid")
			Gui.LockdownFrame.Visible = true
			Humanoid.WalkSpeed = 0
			Humanoid.JumpHeight = 0
		end
	end
end)

Output:

  20:16:38.198  Players.OmqFroko.PlayerGui.LockdownService.LockdownS:9: attempt to index nil with 'WaitForChild'  -  Cliente - LockdownS:9```

This line

local Screen = workspace.Map.CCI.SCW.Decoration.ControlLockdown:FindFirstChild("ScreenPanel")

is coming up as nil

Just make sure to double check the path or maybe even add some waitforchild’s in there

The problem is, I’ve checked it alot of times. The path is correct, I might try to use WaitForChild, but it will be same problem.

I guess if you wanted to triple check and make sure you could put this line in the command bar

print(workspace.Map.CCI.SCW.Decoration.ControlLockdown:FindFirstChild("ScreenPanel"))
1 Like

I’ve become stupid enough to make a post about it than checking it more careful. Welp, that did fixed it up. WaitForChild was the fix. Thank you.

1 Like

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