Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script doesn't work?

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

✓ Accepted answer

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

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.

3 comments

0

Wow, I got beat to the answer twice.

0

Lol, at least u had right answer. Voted up :P

0

Haha, thanks!

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.