Hint text is blank

  1. What do you want to achieve?
    Find out if a server is dead.

  2. What is the issue?
    Hint shows up blank

  3. What solutions have you tried so far?
    Tried looking everywhere

I am in no way shape or form a scripter, this is my first experience with scripting.

local h = Instance.new("Hint")
h.Parent = game.Workspace
if
	game.Players:GetPlayers() < 10 then
	h.Text = "This server is dead!"
elseif
	game.Players:GetPlayers() > 10 then
	h.Text = "This server is not dead!"

end

game.Players:GetPlayers() returns an array so you need to get the length of the array by using #game.Players:GetPlayers().
Also don’t use Hint object for your new works since it got deprecated a while ago.

Hey there!

So the :GetPlayers() function actually returns a table. What you would want to do is loop through that table and count how many items are in that table(Players) You can do this by using a for loop.

local PlayerTable = game.Players:GetPlayers()
local PlayerCount = 0
for count = 1, #PlayerTable do  --#PlayerTable is counting how many items are in the table.
      PlayerCount += 1 --Simply adds 1 to the PlayerCount value each time.
end

Another way of doing this is by just printing the length of the table

local players = #game.Players:GetPlayers()

The loop can be used to get the players names or perform actions on the players. While my second piece of code will only return the count. Use as you wish.

1 Like

Try using Messages, it’s the same as hints, not that it makes a difference to the script i think you already solved your problem it’s just cause the messages are better

Hint is still reliable for me.

1 Like