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

How Can I Make It Sparkles When Click The Brick And Also Make Sound?

Asked by
ImfaoXD 158
9 years ago

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?

01Brick = script.Parent
02Sound = Brick.Sound
03Debounce = false
04 
05function onClicked()
06    if not Debounce then
07        Debounce = true
08        Sound:Play()
09        wait(Sound.TimeLength)
10        Debounce = false
11    end
12end
13 
14script.Parent.ClickDetector.MouseClick:connect(onClicked)

Am I doing this right?

01sparkles = Instance.new("Sparkles")
02sparkles.Parent = Brick
03Brick = script.Parent
04Sound = Brick.Sound
05Debounce = false
06 
07function onClicked()
08    if not Debounce then
09        Debounce = true
10        Sound:Play()
11        wait(Sound.TimeLength)
12        Debounce = false
13    end
14end
15 
16script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 answers

Log in to vote
1
Answered by 9 years ago

To make sparkles, add in:

sparkles = Instance.new("Sparkles", Brick)

Add the line before or after Sound:Play()

0
Can you check if I do it right? Check the second script. ImfaoXD 158 — 9y
0
add the sparkles in directly after the Debounce = true line, and then add a line that says sparkles:Destroy() directly before the Debounce = false line. Legojoker 345 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

You are not calling the variable, so it doesn't spawn, do this:

1sparkles = Instance.new("Sparkles")
2sparkles.Parent = Brick

Edit:

01c = Instance.new("ClickDetector")
02c.Parent = Brick
03s = Instance.new("Sparkles")
04s.Parent = Brick
05s.Enabled = false
06local on = false
07 
08c.MouseClick:connect(function()
09    if on == false then
10        on = true
11        s.Enabled = true
12    else
13        s.Enabled = false
14        on = false
15    end
16end)

There is no ClickEnded event for ClickDetectors.

0
It's still doesn't work. I want to make it sparkle when you click it. And if you don't click it, then it will stop sparkling. Can you check if I made some error? ImfaoXD 158 — 9y
0
What do you mean "if you don't click it"? InfinitivePixelsJr 542 — 9y
0
I think its like the MouseHover event, except with clicking. E.G, Guis MB1Down and MB1Up TheDeadlyPanther 2460 — 9y

Answer this question