I’m currently trying to print the Sound.TimePosition of a sound everytime it changes, while using the :GetPropertyChangedSignal(“TimePosition”) function, but nothing is printing. It only prints
when I change it manually.
Here is the code:
local backgroundMusic = game.Workspace:WaitForChild("BackgroundMusic")
backgroundMusic:GetPropertyChangedSignal("TimePosition"):Connect(function()
print(tostring(backgroundMusic.TimePosition))
end)
r u changing the timeposition of the audio with another script?
btw is this script that’s detecting the timepos change, is it a localscript or server script
if this is a regular script, it wont detect changes done from the client,
unless ur making changes to the timeposition via code, it’s not gonna detect any changes done because it wont have any changes done, if u changed it manually and it’s detecting change, it should print once you change the timeposition from another script
I’m not understanding everything you’re saying (because of your grammar), but this script is a localscript. And the only thing changing the TimePosition of the sound is the sound itself. It’s playing and therefore changing.
Pretty sure TimePosition doesn’t work with GetPropertyChangedSignal.
The way you can choose to use is RunService
local RunService = game:GetService("RunService")
local oldTimePosition = sound.TimePosition -- initial
RunService.RenderStepped:Connect(function()
local pos = sound.TimePosition
if pos ~= oldTimePosition then
oldTimePosition = pos
print(pos) -- only for debugging, it will spam ur console since TimePosition changes every frame if the sound is playing
end
end)
Here sound is the Sound Instance. RenderStepped is the most accurate way you can do this afaik.