I have a script to set the time that a song has been playing when another script sets a value. It utilizes a while true loop until the song finishes. What's wrong with it?
local rs = game.ReplicatedStorage
rs.Music.SongName.Changed:Connect(function()
local currenttime = 0
local totaltime = rs.Music.Seconds.Value
while true do
wait(1)
if currenttime < totaltime then
currenttime = currenttime + 1
if game.ReplicatedStorage.Music.CurrentTime.Seconds.Value > 60 then
game.ReplicatedStorage.Music.CurrentTime.Seconds.Value = game.ReplicatedStorage.Music.CurrentTime.Seconds.Value + 1
elseif game.ReplicatedStorage.Music.CurrentTime.Seconds.Value == 60 then
game.ReplicatedStorage.Music.CurrentTime.Minutes.Value = game.ReplicatedStorage.Music.CurrentTime.Minutes.Value + 1
game.ReplicatedStorage.Music.CurrentTime.Seconds.Value = 0
end
end
end
end)
