Script apparently runs properly but doesn't work and it doesn't show any errors in the output. Can someone help please?

LocalScript:

local Box1 = script.Parent.PlayerName1
local Box2 = script.Parent.PlayerName2
local Box3 = script.Parent.PlayerName3
local Box4 = script.Parent.PlayerName4
local Box5 = script.Parent.PlayerName5
local Box6 = script.Parent.PlayerName6
local Box7 = script.Parent.PlayerName7
local Box8 = script.Parent.PlayerName8
local Box9 = script.Parent.PlayerName9

game.Players.PlayerAdded:Connect(function(player)
	if Box1.Text == "[Un-Ocuppied]" then
		Box1.Text = player.Name
	end
end)

2 comments

0

The code isn't going to run for the Client since their programs don't initialize until they've fully connected; the 'PlayerAdded' signal won't fire for you, only for others who join afterward. In order to do this, create your callback as an actual function rather than an anonymous, then, execute it and then connect it.

0

May you explain to me how to make a callback as a function? I'm new to scripting, sorry if I bother you quite a bit.