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

How Do I Make The Brick Sparkles For An Amount Of Time When Click?

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)

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

4 comments

0

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:

0

it's works, but the sparkle didn't go off. D:

0

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.

0

Alright, let me try. Thank you for the advice! :)

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