song:GetPropertyChangedSignal("TimePosition"):Connect(function()
local length = song.TimeLength
local CurrentPosition = song.TimePosition
local Step1 = length - CurrentPosition
local Step2 = Step1 / length
for i,v in pairs(game.Players:GetPlayers()) do
local musicbar = v.PlayerGui.NewGui.Lobby.Music
musicbar.Bar.Size = UDim2.new(Step2, 0,0.548, 0)
end
end)
hey guys I’m trying to make a sound bar however the code doesnt even fire. Is time position broken or something? how do i tell where they are in the song without it
The time position property doesn’t call the Changed event because that would be very laggy. Try just using a loop to update your sound bar!
while task.wait() do
if song.IsPlaying then
local length = song.TimeLength
local CurrentPosition = song.TimePosition
local Step1 = length - CurrentPosition
local Step2 = Step1 / length
for i, v in pairs(game.Players:GetPlayers()) do
local musicbar = v.PlayerGui.NewGui.Lobby.Music
musicbar.Bar.Size = UDim2.new(Step2, 0,0.548, 0)
end
end
end
local function lerp(a, b, t)
return a + (b - a) * t
end
local function change()
game:GetService("RunService").Heartbeat:Connect(function ()
local completionDecimal = song.TimePosition/song.TimeLength
local barLength = lerp(0, 211, completionDecimal)
game.Players.LocalPlayer.PlayerGui.NewGui.Lobby.Music.Bar.Size = UDim2.fromOffset(barLength,7)
end)
end
hey i already did a bunch and i have another issue right now. I found a post to get to forumla to calculate the size of the bar however it only works on offset (Which is hella gay) how do i do it but with scale because offset SUCKS
I don’t know what that means I don’t work with offset I just know I divided the timeposition by the length which seems to only give me an offset answer.
The completionDecimal variable will most likely be a number between 0 and 1. So just use that as the scale for the size of your soundbar. Something like this: