It's NOT a localscript the error code: attempt to index nil with 'PlayerGui'
The script
01 | function onClicked() |
02 |
03 | local c = game.Players:GetChildren() |
04 | for i = 1 , #c do |
05 | c [ i ] .Character.UpperTorso.CFrame = CFrame.new(script.Parent.Parent.Teleport.Position) |
06 | end |
07 |
08 | player.PlayerGui.Tasksbar.t 1. Visible = true -- the gui |
09 | player.PlayerGui.Tasksbar.t 2. Visible = true -- gui |
10 | player.PlayerGui.Tasksbar.t 3. Visible = true -- gui |
11 |
12 | end |
13 |
14 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
The problem is that the variable "player" isn't defined. There are several ways to get the player, there is 1 main one for the server and another one for the client, to access the player on the server you can add a players.PlayerAdded event to your code, or if the code is on the client use game.Players.LocalPlayer. Also I recommend not using :connect since it's deprecated use :Connect instead.
You don't have player properly defined, fix:
01 | function onClicked() |
02 |
03 | local c = game.Players:GetChildren() |
04 | for i = 1 , #c do |
05 | c [ i ] .Character.UpperTorso.CFrame = CFrame.new(script.Parent.Parent.Teleport.Position) |
06 | c [ i ] .PlayerGui.Tasksbar.t 1. Visible = true -- the gui |
07 | c [ i ] .PlayerGui.Tasksbar.t 2. Visible = true -- gui |
08 | c [ i ] .PlayerGui.Tasksbar.t 3. Visible = true -- gui |
09 |
10 | end |
11 |
12 |
13 | end |
14 |
15 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
Because you're getting a table of players and referencing an index for each player, therefore c[i] represents the current player, so you can adjust each gui like that.