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

Script doesn't work?

Asked by 9 years ago
local text = script.Parent.Text
t = 5

local players = game.Players:GetChildren()

while true do
    text = "Game made by n2q."
    wait(t)
    text = "Found any bugs or have any ideas for the game? Message n2q!"
    wait(t)
    if #players >= 1 then
        text = "There are currently " ..#players.. " players online."
    else
        text = "There is currently " ..#players.. " player online."
    end
    wait(t)
end

I couldn't find anything wrong in here but it still didn't work. By the way, this script is inside a TextLabel.

3 answers

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

I only see one simple mistake. The problem is that you defined a variable "text" and tried to use that as the labels "text" property. You can't do that. Once the variable is set, it's completely separate from the labels property. Try this:

local text = script.Parent
t = 5

while true do
local players = game.Players:GetChildren()
    text.Text = "Game made by n2q."
    wait(t)
    text.Text = "Found any bugs or have any ideas for the game? Message n2q!"
    wait(t)
    if #players >= 1 then
        text.Text = "There are currently " ..#players.. " players online."
    else
        text.Text = "There is currently " ..#players.. " player online."
    end
    wait(t)
end

I changed the variable to the label itself, then found the "text" property for each different time the text changed (I also moved the player finder into the loop, so it updates with the game instead of running off the first update the entire time). Hope this helps :P

Ad
Log in to vote
2
Answered by 9 years ago

The problem here is that you defined the variable "text" as script.Parent.Text. The problem with that is that when you redefine "text", you define it as a string, not as text's Text property. The easiest solution is to define "text" as script.Parent.

local text = script.Parent
t = 5

local players = game.Players:GetChildren()

while true do
    text.Text = "Game made by n2q."
    wait(t)
    text.Text = "Found any bugs or have any ideas for the game? Message n2q!"
    wait(t)
    if #players >= 1 then
        text.Text = "There are currently " ..#players.. " players online."
    else
        text.Text = "There is currently " ..#players.. " player online."
    end
    wait(t)
end

The script should work just find now. If you found this answer helpful, you can upvote and accept it! If you have any questions, just ask.

0
Wow, I got beat to the answer twice. IcyArticunoX 355 — 9y
0
Lol, at least u had right answer. Voted up :P dyler3 1510 — 9y
0
Haha, thanks! IcyArticunoX 355 — 9y
Log in to vote
0
Answered by
nilVector 812 Moderation Voter
9 years ago

Instead of setting text equal to script.Parent.Text, set it just equal to script.Parent. Then, when you want to change the text, you would do it by saying text.Text = "String". The reason for this is when you already have a the text saved into the variable, it will save the String Value, NOT the property of the TextLabel.

Answer this question