I want to add effects like sparkles to brick and when you click it, the sound will play and also sparkling. How can I do that?
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)
Am I doing this right?
sparkles = Instance.new("Sparkles") sparkles.Parent = Brick 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)
To make sparkles, add in:
sparkles = Instance.new("Sparkles", Brick)
Add the line before or after Sound:Play()
You are not calling the variable, so it doesn't spawn, do this:
sparkles = Instance.new("Sparkles") sparkles.Parent = Brick
Edit:
c = Instance.new("ClickDetector") c.Parent = Brick s = Instance.new("Sparkles") s.Parent = Brick s.Enabled = false local on = false c.MouseClick:connect(function() if on == false then on = true s.Enabled = true else s.Enabled = false on = false end end)
There is no ClickEnded event for ClickDetectors.