Hello again my last topic involving sprite sheets and animation was just something I was seeing i could get help or find something out it was just a general debate about something to possible try and add but ill work on that later on! anyways I’ve been looking around and I still am, but I cant find a very well explaining tutorial of something I want my gui to do…
I’ve already added my gui and the effects for it but now i need to make the main works of it, i want to make my button when I click it it makes a sound and a box resizes to show the options of the current button while my other controls on the gui fade and a way to reverse it
immediately after getting to work I’m stuck at the sound part where when i click it i have to click it again for the sound to stop and play again and if i loop it the same thing but the sound continues ill put my code below
local long = 0
script.Parent.MouseButton1Down:connect(function()
if bop == false then
script.Parent.click.TimePosition = long
script.Parent.click:Play()
bop = true
else
long = script.Parent.bip.TimePosition
script.Parent.click:Stop()
bop = false
end
end)
if you need more detail I don’t really have other contacts other then discord which is ! Troublemaiker#2321 but i am going to continue searching about my topic more
You need to add a wait(script.Parent.click.TimePosition) before assigning the bop variable to true and the wait function will pause the script until the sound ends
You can maybe try replacing the script.Parent.click:Stop() with script.Parent.click.Playing = false
local long = 0
script.Parent.MouseButton1Down:connect(function()
if bop == false then
script.Parent.click.TimePosition = long
script.Parent.click:Play()
wait(script.Parent.click.TimePosition)
bop = true
else
long = script.Parent.bip.TimePosition
script.Parent.click:Stop()
bop = false
end
end)
I’m not sure if this answer your problem but if you’re planning to make a button SFX that only play once per click then here might be what you’re looking for.
script.Parent.MouseButton1Down:connect(function()
script.Parent.click:Stop()
-- Stop the sound incase it is still playing
script.Parent.click:Play()
-- Play the sound once
end)
If you however want the sound to play once you click it and pause right after you click it again and play it again once you click it again and so on, here might be what you’re looking for.
script.Parent.MouseButton1Down:connect(function()
if bop == false then
if not script.Parent.click.Playing then
script.Parent.click:Play()
else
script.Parent.click:Resume()
end
bop = true
else
script.Parent.click:Pause()
bop = false
end
end)