Code refuses to work?

So… As mentioned, the code wont work. The playeradded is working which isn’t the problem and i am even running checks to make sure that everything inside is a text button. Not even the playercheck will work. Does anybody know how to fix this?

game.Players.PlayerAdded:Connect(function(plr)
	print("Hello!")
	playerCount +=1
	if playerCount > 0 then
		plr.PlayerGui.warning.Enabled = false
		plr.PlayerGui.carselector.ImageLabel.Visible = true
		local z = plr.PlayerGui.carselector.ImageLabel.Frame.Frame.ScrollingFrame.Frame:GetChildren()
		for i,v in ipairs(z) do
			if v:IsA("TextButton") then
				print("All is textbutton")
			v.Activated:Connect(function()
				workspace.carselectors.Value +=1
				if workspace.carselectors.Value > 0 then
					local module = require(plr.PlayerGui.ready.ModuleScript)
					module.Start()
					end
				end)
			end
		end
	end
end)

Never mind, I thought you said the PlayerAdded event wasn’t working

Does it print “Hello!”?

Don’t use v.Activated, use v.MouseButton1Up. Activating aren’t based off of player input

1 Like

Hello. Firstly, you aren’t checking if the “PlayerGui” exists.

if playerCount > 0 then
   local PlayerGui = plr:WaitForChild("PlayerGui", 30)

If the PlayerGui does not exist, then the code will obviously error. Continue from there.

Do click events even work on the server? Didn’t think those we’re replicated.

I don’t know about events, but did you know could set things visible or not visible?

It says that warning is not a part of PlayerGui.

Nevermind.

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