Hello, i made a script that would look how many players there are in a server, whenever it’s higher or equal to two players, the round will start. whenever there are not enough players or enough players, the script should make the UI visible and say if it’s not enough or there is enough. but for some reason, the script enabled the UI but wont make the text appear ingame, but in studio when i enable it, it appears.
here’s my code:
local playercount = 0
local Grow = game.Workspace.Grow
local textchange = game.ReplicatedStorage:WaitForChild("TextChanger")
game.Players.PlayerAdded:Connect(function(plr)
playercount = playercount + 1
print('player added')
local text = plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel")
wait(5)
if playercount >= 2 then
print("Enough players.")
if game.StarterGui.ScreenGui.Enabled == false then
game.StarterGui.ScreenGui.Enabled = true
textchange:FireAllClients("ScreenGui", "TextLabel", "Round starting in 5 seconds.")
wait(5)
game.StarterGui.ScreenGui.Enabled = false
end
while true do
wait(0.01)
Grow.Size = Grow.Size + Vector3.new(0.03,0,0)
Grow.Position = Grow.Position + Vector3.new(0,0.015,0)
end
else
print('not starting')
if game.StarterGui.ScreenGui.Enabled == false then
game.StarterGui.ScreenGui.Enabled = true
print("UI enabled.")
textchange:FireAllClients("ScreenGui", "TextLabel", "Not enough players.")
--wait(5)
--game.StarterGui.ScreenGui.Enabled = false
end
end
end)
game.Players.PlayerRemoving:Connect(function()
playercount = playercount - 1
print('player removed')
end)
Here are photos with explanation.
Enables the UI and the UI should show up.
as you can see, on the right it says its enabled but you cant see anything, the textlabel is visible.
Now we will enable it when we are not ingame, lets see if it is visible.
hmm thats weird, when im not in the game, it shows. but when im in it, it doesnt.
anybody got a fix?