So I am making a minigame and I was just making it so the textlabel would say all the stuff like etc... I testing it many times in studio mode and it worked then i tested it in the actual game and it didn't work can anyone help me with this?
Repstore = game.ReplicatedStorage maps = Repstore.Maps:GetChildren() while true do if game.Players.NumPlayers > 1 then for i, v in pairs(game.Players:GetChildren()) do pgui = v:WaitForChild("PlayerGui") pgui:WaitForChild("MainText").TextLabel.Text = "Not enough players to start!" end else for i, v in pairs(game.Players:GetChildren()) do pgui1 = v:WaitForChild("PlayerGui") pgui1:WaitForChild("MainText").TextLabel.Text = "Chosing map" wait(3) ranGame = math.random(1, #maps) gameChosen = maps[ranGame] for i, v in pairs(game.Players:GetChildren()) do pgui2 = v:WaitForChild("PlayerGui") pgui2:WaitForChild("MainText").TextLabel.Text = "Map chosen: ".. gameChosen.Name wait(3) gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace.MapSelected wait(3) spawns = gameChosenClone.Spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers())do name = v.Name check = game.Workspace:FindFirstChild(name) if check then checkHumanoid = check:FindFirstChild("Humanoid") if checkHumanoid then check:MoveTo(spawns[i].Position) end end end end end for i, v in pairs(game.Players:GetChildren()) do for i = 3, 1, 1 do pgui3 = v:WaitForChild("PlayerGui") pgui3:WaitForChild("MainText").TextLabel.Text = "Game begins in".. i wait(1) end for i, v in pairs(game.Players:GetChildren()) do for i = 10,1, -1 do pgui4 = v:WaitForChild("PlayerGui") pgui4:WaitForChild("MainText").TextLabel.Text = "Time left ".. i wait(1) end end end for i, v in pairs(game.Players:GetChildren()) do pgui5 = v:WaitForChild("PlayerGui") pgui5:WaitForChild("MainText").TextLabel.Text = "Game ended" wait(3) gameChosenClone:Destroy() for i, v in pairs(game.Players:GetChildren()) do for i = 60,1,-1 do pgui6 = v:WaitForChild("PlayerGui") pgui6:WaitForChild("MainText").TextLabel.Text = "Intermission ".. i end end end end wait(1) end
Hey there, there are a few errors with your code.
Client-Server Replication
With FilteringEnabled now being a mandatory thing, client to server replication is more important then ever. Server Scripts cannot access a player's PlayerGui
, and Local Scripts cannot access certain services such as ServerStorage
and ServerScriptService
. You'll have to use RemoteEvent
s and RemoteFunctions
to get around this and other restrictions.
Hints
The Hint
object has been deprecated in favor of TextLabel
s. You should not use a Hint, rather use a TextLabel at the top of the screen.
A little side-note:
It is not recommended to use the 2nd argument of Instance.new
. You should instead set it's parent via .Parent = X
.
It's good practice to change your variables into local
variables.