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
01sparkles = Instance.new("Sparkles")
02sparkles.Parent = Brick
03wait(5)
04Brick = script.Parent
05Sound = Brick.Sound
06 
07function onClicked()
08Sound:Play()
09end
10 
11script.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:

01local Brick = script.Parent
02local Sound = Brick.Sound
03 
04function onClicked()
05sparkles = Instance.new("Sparkles")
06sparkles.Parent = Brick
07Sound:Play()
08wait(5)
09sparkles:Destroy()
10Sound:Stop()
11end
12 
13script.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