"Attempt to index nil with MouseButton1Click"

As I said, it happens at random times with different scripts

We need to take 1 error at a time.

image

And the handler script please.

local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local plrgui = plr.PlayerGui
local gui = plrgui:WaitForChild("GUI")
local frame = gui:WaitForChild("BallCam")
local button = script.Parent

button.MouseButton1Click:Connect(function()
	if frame.Visible == true then
		frame.Visible = false
		workspace.CurrentCamera.CameraSubject = workspace:FindFirstChild(plr.Name , math.huge):WaitForChild("Humanoid" , math.huge)
		frame:WaitForChild("Frame").BallCurrent.Text = "No Balls Found"
	elseif frame.Visible == false then
		frame.Visible = true
		
	end

	
end)

Look at your script, BallCam is your button. Try and remove the line. You’re trying to wait for the “parent” of the script to be there, before running the script.

You mean this line?
local frame = gui:WaitForChild("BallCam")

Yes, your “frame” variable and “button” variable defines the same object.

The error still isnt fixed, and now I got a whole load of others

Only have this localscript enabled while you work on fixing it, we cannot focus on other errors before this one is fixed. I would also suggest only having 1 local script for each gui at most. (sometimes 2 if it’s a gui handling a lot of stuff, but I personally split up my gui into two guis then)

Ok I only have this script enabled now… If you want I can invite you to Team Create.

Also I noticed. When I asked you to remove

local frame = gui:WaitForChild("BallCam")

Change the script to be:

local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local plrgui = plr.PlayerGui
local gui = plrgui:WaitForChild("GUI")
local frame = gui:WaitForChild("Frame") -- Changed this from waiting for "BallCam" to "Frame"
local button = script.Parent

button.MouseButton1Click:Connect(function()
	if frame.Visible == true then
		frame.Visible = false
		workspace.CurrentCamera.CameraSubject = workspace:FindFirstChild(plr.Name , math.huge):WaitForChild("Humanoid" , math.huge)
		frame:WaitForChild("Frame").BallCurrent.Text = "No Balls Found"
	elseif frame.Visible == false then
		frame.Visible = true
		
	end
end)

Sure, I can take a look at your scripts.

Oh yeah the “GUI” is a completly different screen gui.
image

Oh right, didn’t even notice that. Let me know when you’ve invited me.

You need to add me to edit it, should I just send the place file in your DM’s?

make sure the variable to the button is game.Players.LocalPlayer.PlayerGui.ScreenGui.Button

or whatever the directory is

Yeah it already is, thanks for helping though.

Yea send me the file in my DM’s.

Edit: The issue was, that he had multiple PlayerAdded events. Which resultet in unsyncronized behavior.