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

How do I hint message rotation script?

Asked by 8 years ago

I'm trying to make a script that plays a song on repeat and scycles through messages, Here is the code I have so far

local ws = game.Workspace
local SoundId = 145462567  -- Sound Id Of The Sound
    local Asset = game:GetService("MarketplaceService"):GetProductInfo(SoundId) --[[Get's Product Information Of The Sound--]]

local freedom = Instance.new("Sound")
freedom.Name = "Freedom"
freedom.Pitch = 0.4
freedom.Volume = 1
freedom.SoundId = SoundId
freedom.Looped = true
freedom.Parent = game.Workspace

local todcheck = 100

local stime = 5

local currentSongMessage = Instance.new("Hint")
freedom:Play()
currentSongMessage.Text = "Now playing: ".. Asset.Name.." on loop"
currentSongMessage.Parent = game.Workspace
currentSongMessage.Name = "BGMMessage"
while true do
    wait(5)
    while todcheck > 0 do
        currentSongMessage.Text = "The current time of day is "..game.Lighting.TimeOfDay
        wait(0.01)
        todcheck = todcheck - 1
    end
    todcheck = 100
    currentSongMessage.Text = "Now playing: ".. Asset.Name.." on loop" 
    wait(1)
    while stime > 0 do
        currentSongMessage.Text = "The server has been up for ".. ws.ServerHours.." hours "..ws.ServerMin.." minutes "..ws.ServerSec.." seconds"
        wait(1)
        stime = stime - 1
    end
    stime = 5
end


The output of this code is the hint of the "Now playing: Freedom by Sotero Ange on loop" then it goes to the time of day then it goes back to the nowplaying message and then stops.

The code for my server time getter is as follows (the ServerSec,Min,Hour are Number variables in the game.Workspace)

sec = game.Workspace.ServerSec
minu = game.Workspace.ServerMin
hours = game.Workspace.ServerHour
while true do
    wait(1)
    sec = sec + 1
    if sec == 60 then
        sec = 0
        minu = minu + 1
    end
    if minu == 60 then
        minu = 0
        hours = hours + 1
    end
end

Answer this question