Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this not work for 2 or more players? (Gui)

I made a script it works perfect but one problem.. just for one player tested for two players and it doesn't work just one time but not a second time. How can this get fixed? Thanks.

Script in Workspace and Gui in script*

game.Players.PlayerAdded:connect(function (Players)

	while true do
		wait (5)
		a = script:findFirstChild("EventsGui"):Clone()
		a.Parent = Players.PlayerGui
		wait (5)
		a.Parent = Players.PlayerGui:findFirstChild("EventsGui"):remove()
	end
end)

2 answers

✓ Accepted answer

It's probably because of line 8 for two reasons:

  1. :Remove() is deprecated so it would be better to use :Destroy()

  2. You're making the parent of a script itself and then destroying the script.

After getting the error on line 8, it probably stops the entire script.

1 comment

0

I founded the problem and changed it to destroy thanks!

Your most likely not using a local script. GUIs usually use local scripts to perform single player functions. Keep in mind however you may need to change your code if you change a script to a local script.

1 comment

0

The script is a part of the Disaster script so it need to be one big script for all players.

This discussion is preserved as it was. New answers, comments, and votes are closed.