Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

To make sparkles, add in:

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

Add the line before or after Sound:Play()

2 comments

0

Can you check if I do it right? Check the second script.

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.

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.

3 comments

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?

0

What do you mean "if you don't click it"?

0

I think its like the MouseHover event, except with clicking. E.G, Guis MB1Down and MB1Up

This discussion is preserved as it was. New answers, comments, and votes are closed.