sparkles = Instance.new("Sparkles")
sparkles.Parent = Brick
wait(5)
Brick = script.Parent
Sound = Brick.Sound
function onClicked()
Sound:Play()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
COMMUNITY QUESTION
How Do I Make The Brick Sparkles For An Amount Of Time When Click?
1 answer
The complete code is almost completely good, just have to add a few more things. The finish code would be:
local Brick = script.Parent
local Sound = Brick.Sound
function onClicked()
sparkles = Instance.new("Sparkles")
sparkles.Parent = Brick
Sound:Play()
wait(5)
sparkles:Destroy()
Sound:Stop()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
hope this helped! i
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
You need to set the values to local values aswell for them to be able to be accessed by the onClicked function and an easier thing to do would be to Instance.new("Sparkles") in the onclicked function, then the sound will play, wait 5 seconds, sparkles will be destroyed and sound will be stopped c:
it's works, but the sparkle didn't go off. D:
Change the script to have a debounce with an if statement checking for that debounce, and make sparkles a local variable. It probably overrode itself when a new instance was created inbetween the wait.
Alright, let me try. Thank you for the advice! :)