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

Automatically sets the Bool to false?

Asked by 8 years ago

When the music plays it should set the bool to true, then wait(song.TimeLength) to change back to false, but it doesn't?

When the song is played the bool just stays false..?

--[[SONG SCRIPT]]--

local song = script.Parent.Parent.Parent.Song
local value = script.Parent.Parent.Parent.CurrentlyPlaying
local value2 = script.Parent.Parent.Playing
local id = script.Parent.ID.Value
local timev = script.Parent.Parent.Parent.BAR.Time

function clicked(player, name)
    if value.Value == false then
    value.Value = true
    value2.Value = script.Parent.Text
    song.SoundId = "rbxassetid://"..(id)
    song:Play()
    wait(song.TimeLength)
    song:Stop()
    value.Value = false
    end
end
script.Parent.MouseButton1Down:connect(clicked)


2 answers

Log in to vote
0
Answered by 8 years ago

TimeLength doesn't work on the server
Consider moving to a LocalScript, or using the Ended event instead.

Why? The server doesn't actually load the sound, and doesn't even play it. It simply tells the clients to play it, and they load the sound themselves. In fact, the server doesn't even know that the clients are all playing the same sound. As a result, it simply has no way of determining how long the sound is.

0
STOP STEALING STUFF I WANT TO ANSWER LUNATE >:O koolkid8099 705 — 8y
0
You didn't answer it, and I was in Studio for most of the time. Be faster or provide better answers. User#6546 35 — 8y
0
I have another script that works on TimeLength though..? and it works perfectly? @kool put in your answer too UnleashedGamers 257 — 8y
0
When you find a better solution that answers your question, please do tell me. User#6546 35 — 8y
0
I posted it down below. UnleashedGamers 257 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

I figured it out, this works perfectly.


local SoundInstance = game.Workspace.VritixConsole.MainWall.SurfaceGui.Song local id = script.Parent.ID.Value local value = script.Parent.Parent.Parent.CurrentlyPlaying x =1 function run() SoundInstance.SoundId="rbxassetid://"..id wait(1) song=SoundInstance song:Play() for i=1,10 do song.Volume = song.Volume + 0.1 wait(0.1) end wait(song.TimeLength) for i=1,10 do song.Volume = song.Volume - 0.1 wait(0.1) end song:Stop() value.Value = false wait(1) end function click() if value.Value == false then value.Value = true run() else if value.Value == true then print "Another song is already playing!" end end end script.Parent.MouseButton1Down:connect(click)
0
I stand corrected. Does this mean that TimeLength is no longer broken? User#6546 35 — 8y
0
I believe that in some forms that it can break like my first script, but it can work if you script it right. UnleashedGamers 257 — 8y

Answer this question