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
8 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?

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)

2 answers

Log in to vote
1
Answered by 8 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 — 8y
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 — 8y
Ad
Log in to vote
1
Answered by 8 years ago

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.

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 — 8y
0
What do you mean "if you don't click it"? InfinitivePixelsJr 542 — 8y
0
I think its like the MouseHover event, except with clicking. E.G, Guis MB1Down and MB1Up TheDeadlyPanther 2460 — 8y

Answer this question