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

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

Asked by
ImfaoXD 158
9 years ago
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

Log in to vote
2
Answered by 9 years ago

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

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: disassembling 48 — 9y
0
it's works, but the sparkle didn't go off. D: ImfaoXD 158 — 9y
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. Legojoker 345 — 9y
0
Alright, let me try. Thank you for the advice! :) ImfaoXD 158 — 9y
Ad

Answer this question