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

on touch of baseplate smoke comes for 2.8 seconds and sound plays?

i have this so far!

function onTouched(part)

while true do

wait(2)
script.Workspace.Baseplate.ontouch.Smoke.Enabled = true
end
end

script.Parent.Touched:connect(onTouched)

i need it to end in 2.8 secs

1 answer

I wrote this on mobile.

local beingTouched = false
workspace.Baseplate.Touched:Connect(function(touch)
       if not beingTouched then 
             beingTouched = true
             
             sound:Play()
             smoke.Enabled = true

             wait(2.8)
             
             sound:Stop()
             smoke.Enabled = false

             beingTouched = false
       end
end)

Ok so when the baseplate is touched it connects a function to that touch. (I used an anonymous function by just creating the function inside the connect method) It will check beingTouched is false (the not operator is for r opposite. if not true then basically) It sets our var to true so the code block doesn't run the effects again for another 2.8 seconds (cant pass first check again now). It plays the song and enables smoke, waited 2.8 stops the music and smoke, changes var back to false so it can run the code block again.

4 comments

0

wow thanks! i'll try it!

0

Well, the smoke stays..

0

This works, but the smoke has a lifetime of seconds it has until it fades away.

0

Well that was the objective I thought, Sickings. If OP was several he can add a new smoke instances and debris.

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