While loop keeps on repeating

Hey so basically I’m experiencing a problem were the while loop for a player list keeps on looping for some reason

-- local script
-- server script in frame that has the names of the players
local WWII = workspace.WWIIfolder

while true do 
		local String = Instance.new("StringValue", WWII)
	    String.Name = player.Name
		print("another player")
		script.Parent.Visible = true
		local PlayerName = Instance.new("TextLabel", script.Parent)
		PlayerName.BorderSizePixel = 0
		PlayerName.Text = player.Name

I’m very sure, it is supposed to wait until someone else clicks the button again, but I guess not…

Just remove the loop entirely as it’s not important for running the function you connected to the OnServerEvent event connection. Events don’t work like conditions and will run the connected function on their own when the event is triggered.

Only thing is that I have a parameter for the OnServerEvent.

The player parameter? Just a bit confused why the loop is required for this?

So basically I was just adding the loop there so it would keep on repeating as a test and only print the players name the first time and not any other time. (and also the ‘player’ variable is a local variable as well so that’s why)

Simply remove the loop, as that’s the issue that you’re experiencing concurrently. The OnServerEvent will fire once a client has fired it, so it’s pointless to add a loop above it - if you thought about this.

If you’re making it so it waits until someone else clicks on it again, add a table, insert them to a table, or do anything similar to this - so when it fires, insert them to a table or whatever, and you’re set.

While loops do tend to run, that’s their main function. You haven’t added a break in the loop so of course it will continue to run.