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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

0
wow thanks! i'll try it! oofoofofofooof 2 — 6y
0
Well, the smoke stays.. oofoofofofooof 2 — 6y
0
This works, but the smoke has a lifetime of seconds it has until it fades away. hellmatic 1523 — 6y
0
Well that was the objective I thought, Sickings. If OP was several he can add a new smoke instances and debris. EpicMetatableMoment 1444 — 6y
Ad

Answer this question