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

The text label's text isn't changing accordingly. Why and how can I fix it?

Asked by 4 years ago

I'm trying to make a random music player script. I'm adding more songs but here is what I've got for now. What do I have to fix and or what did I do wrong?

title = game.StarterGui.He.Box.Song
function Playsong()
local number = math.random(1,2)
if number == 1 then
    script.Sound1:Play()
    title.Text = "Hate Me"
    wait(15)
    script.Sound1:Stop()
    title.Text = "No Song Playing"
    wait(3)
    title.Text = "Loading Song"
    wait(3)
    Playsong()
else if number == 2 then
    script.Sound2:Play()
    title.Text = "Stitches"
    wait(120)
    script.Sound2:Stop()
    title.Text = "No Song Playing"
    wait(1)
    title.Text = "Loading Song"
    wait(1)
    Playsong()
end
end
end


Playsong()
1
elseif should not have a space in it IDKBlox 349 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hello,

You've made mistakes on several lines so I will copy your Lua code and add corrections where you've gone wrong.

title = game.StarterGui.He.Box.Song -- Should be game.Players.LocalPlayer.PlayerGui.He.Box.Song
function Playsong()
local number = math.random(1,2)
if number == 1 then
    script.Sound1:Play()
    title.Text = "Hate Me"
    wait(15)
    script.Sound1:Stop()
    title.Text = "No Song Playing"
    wait(3)
    title.Text = "Loading Song"
    wait(3)
    Playsong()
else if number == 2 then -- 'Else if' doesn't exist. It's just 'elseif'
    script.Sound2:Play()
    title.Text = "Stitches"
    wait(120)
    script.Sound2:Stop()
    title.Text = "No Song Playing"
    wait(1)
    title.Text = "Loading Song"
    wait(1)
    Playsong()
end
end
end


Playsong()

If this answers your problem perfectly, then make sure to make this an accepted answer. If you have any questions also just comment them.

0
The Random.new():NextInteger(1,2) does that go after Local Number =? CJ_Angel 7 — 4y
0
yep avengerstar 74 — 4y
Ad

Answer this question