Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

Log in to vote
1
Answered by
IXLKIDDO 110
9 years ago

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.

0
I founded the problem and changed it to destroy thanks! minetrackmania 186 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

0
The script is a part of the Disaster script so it need to be one big script for all players. minetrackmania 186 — 9y

Answer this question