How do I put these two scripts into one script? I want to put the sparkles script with the sound script so that when you click the brick, both will work at the same time. For example; when you click the brick, the sparkles will come out and the sound will play. But also, how do I make it sparkles for a short period of time without sparkling forever? I try to put the two script in together and it isn't working. Can somebody help me?
(Sparkles Script) I don't know if I did this right, but I want the sparkles script to sparkles for a short period of time instead of sparkling forever when click.
function onClicked() script.Parent.Sparkles.Enabled = true wait(3) script.Parent.Sparkles.Enabled = false end script.Parent.ClickDetector.MouseClick:connect(onClicked)
And (Sound Script)
Brick = script.Parent Sound = Brick.Sound Debounce = false function onClicked() if not Debounce then Debounce = true Sound:Play() wait(Sound.TimeLength) Debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Thank you for your helps!
Try this:
local Brick = script.Parent local Sound = Brick.Sound local Debounce = false --remove local if it doesnt work. function onClicked() script.Parent.Sparkles.Enabled = true wait(3) script.Parent.Sparkles.Enabled = false if not Debounce then Debounce = true Sound:Play() wait(Sound.TimeLength) Debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Try this:
Brick = script.Parent Sound = Brick.Sound Debounce = false function onClicked() if not Debounce then Debounce = true Sound:Play() script.Parent.Sparkles.Enabled = true wait(Sound.TimeLength) Debounce = false script.Parent.Sparkles.Enabled = false end