8ball script (debug)

Hi, noob programmer here
I’m making an 8ball script as one of my first projects

So it works… kind of.
The script is supposed to change a TextLabel’s property, which is the text.

After it changes the first text, it’s supposed to change the text again, but for some reason, it’s stuck in the first text.

game.Players.LocalPlayer.PlayerGui.Eightball.AnswerDisplay.TextLabel.Text = ". . ."
--Works/Changes text
wait(2)

local Number = math.random(1,10)
if Number == 1 then 	game.Players.LocalPlayer.PlayerGui.Eightball.AnswerDisplay.TextLabel.Text 
= ("It is certain")
--Doesn't work/stays in the "..." text

What am I doing wrong?

Don’t use parenthesis for changing text. () < don’t use that

3 Likes

Oh yeah. I keep forgetting, I’ll try this right now

I feel stupid right now, but this worked, thanks!

Do not put parenthesis only put " "

1 Like

also I recommend using a table instead of if statements to check the number value

using a table would make it much easier to edit

1 Like

Are you looping through the script or is this the entire script?
If the script runs once then it starts with Text = “…”, then produces a random number. If that Number == 1 it’s going to try to change the Text, but if it isn’t the Text won’t change, and the script ends and doesn’t run again.

1 Like

Is there an error in the output? is this code in a local script or server script? try to use Instance | Roblox Creator Documentation

1 Like

Status: it worked a moment ago but for some reason it doesn’t work? Also when i last used the script it would only work once. bit confused

and to answer your questions i have no idea what tables or instance.waitforchild is
also theres 10 answers not just 1 it was a sample

Is there 10 answers?
You don’t show enough of the script to let us know what is actually happening.
From the script section you posted it only chooses 1 random number between 1 and 10, then the script stops.

1 Like

It just loops as if number ==2 then (change the text) until if number ==10

You forgot to finish the if statement with an end

Needs to be

if Number == 1 then 	game.Players.LocalPlayer.PlayerGui.Eightball.AnswerDisplay.TextLabel.Text 
= ("It is certain")
--Doesn't work/stays in the "..." text
end
1 Like
if Number == 1 then
    game.Players.LocalPlayer.PlayerGui.Eightball.AnswerDisplay.TextLabel.Text 
= ("It is certain")
    --Doesn't work/stays in the "..." text
end
1 Like

this is a sample of the script dw

Show us your complete script.
This script doesn’t loop, it only has an if statement after it picks a random number from (1,10).

It almost sounds from your description that you think math.random(1,10) is looping from 1 to 10. It isn’t.