Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My hint script doesn't work?

Asked by
Relatch 550 Moderation Voter
9 years ago
wait(3)
h = Instance.new("Hint", game.Workspace)
plrs = game.Players:GetPlayers()

function StartGame()
    if #game.Players:GetChildren() > 1 then
        h.Text = "Welcome to MrSmeny and MrSmenryBackup's Sword Fighting Tournament!"
        wait(3)
        h.Text = "The rules are simple, sword fight other people in duels and win!"
        wait(3)
        h.Text = "Please wait, loading map and deciding players."
        wait(3)
        h.Text = "This game is in beta, come back later."
    else
        h.Text = "There must be 2 or more players to start. Invite some friends."
    end
end

When I get 2 players in the game, my hint is empty. Why is that?

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

From the snippet you have provided, nothing ever calls the StartGame function. Since nothing calls it, the code inside will never execute.

Continuously (every few seconds or fractions of a second) call StartGame, in, for example, a while loop.


It would also probably be wise to return success or failure. (e.g., return true in the then block and return false in the else block)

Ad

Answer this question