What I'm trying to do is display the current time position of a song/audio I have on a surfaceGUI, it plays it fine, but I can't find out how to display the current time inside the song. (e.g. say the song is halfway through and it is 60 seconds long, the text box would say 30)
local Song = game.Soundscape.Centuries -- Centuries is an already made sound in the Soundscape local Myself = script.Parent while Song:IsPlaying() do -- while the song Centuries is playing, do this. Myself.Text = Song.TimePosition -- Displays the time on the text wait(1) --To prevent lag end
Currently the script is having a problem with Song:IsPlaying()
.
the Output states: Attempt to call method IsPlaying (a boolean value)
What am I doing wrong? Is there an easier way to do what I'm trying to do? (Sorry if this seems a tiny bit sloppy, this is my first question posted).
Edited:
wait(1) --To wait for client to load. local Song = game.Soundscape.Centuries -- Centuries is an already made sound in the Soundscape local Myself = script.Parent while Song.IsPlaying do -- while the song Centuries is playing, do this. print("I've gotten into the while script!") Myself.Text = Song.TimePosition -- Displays the time on the text wait(1) --To prevent lag end
Says nothing and does nothing now that I've fixed it to this.
This is a simple fix. IsPlaying
is a property of a sound object not a method. In order to fix this you would change the line in the script to:
while Song.IsPlaying do
A sound object has many properties including TimePosition, IsPlaying and IsPaused. Methods that can be passed over a sound object include :Play() and :Stop(). A property is a state of an object which can be read and in some cases written to. A method will act upon the object and cause something to happen to it. With :Play(), it will invoke the sound object to begin playing.
EDIT:
I was able to get this to work. The Soundscape is no longer a thing apparently, it is now SoundService.
wait(1) --wait for client stuff to load, not noticeable by player local song = game.SoundService.Sound local me = script.Parent while song.IsPlaying do me.Text = song.TimePosition wait(1) end