It needs to find all the players so it can change the Properties of a PlayerGui. Here's my script:
01 | script.Parent.MouseButton 1 Click:Connect( function () |
02 | local Slot = script.Parent.Parent.Parent.Parent:GetChildren() [ math.random( 1 ,#script.Parent.Parent.Parent.Parent:GetChildren()) ] |
03 | if Slot.Name = = "Slot1" then |
04 | if Slot.Visible = = false then |
05 | script.Parent.Parent.Visible = false |
06 | local players = game.Players:GetChildren() |
07 | for i = 1 ,#players do |
08 | game.Players [ i ] .PlayerGui.MainGui.Missions [ Slot.Name ] .Visible = true |
09 | game.Players [ i ] .PlayerGui.MainGui.Missions [ Slot.Name ] .Difficulty.Text = script.Parent.Parent.Vals.Difficulty.Value |
10 | game.Players [ i ] .PlayerGui.MainGui.Missions [ Slot.Name ] .Host.Text = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name |
11 | game.Players [ i ] .PlayerGui.MainGui.Missions [ Slot.Name ] .Mission.Text = script.Parent.Parent.Vals.Mission.Value |
12 | game.Players [ i ] .PlayerGui.MainGui.Missions [ Slot.Name ] .Players.Text = "Players: 1/4" |
13 | game.Players [ i ] .PlayerGui.MainGui.Missions [ Slot.Name ] .Host.HostName.Value = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name |
14 | game.StarterGui.MainGui.Missions [ Slot.Name ] .Visible = true |
15 | game.StarterGui.MainGui.Missions [ Slot.Name ] .Difficulty.Text = script.Parent.Parent.Vals.Difficulty.Value |
Anything wrong with it?
when you do game.Players[i]
, it's interpreted as you literally trying to get a property or child that's named 1 (not a string, but a number)
what you should be doing instead is game.Players:GetPlayers()[i]
or in your case, since you already got the players, players[i]