1: the script below unanchors all parts of a group and emits smoke when touched. is there a way it can also make a sound when touched? and what will be the locations. 2: can there be a cooldown on the smoke emitter and sound
local function emitSmoke()
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
end
wait(2) -- Amount of till making smoke dissapear
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Smoke:Destroy()
end
end
script.Parent.Touched:Connect(emitSmoke)
local ready = true
local sound = script.Parent.Sound--Change to your sound location.
local function emitSmoke()
if ready == true then
ready = false
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
end
sound:Stop()
sound:Play()
wait(2) -- Amount of till making smoke dissapear
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Smoke:Destroy()
end
ready = true
end
end
script.Parent.Touched:Connect(emitSmoke)
local SP = script.Parent
function onTouch (hit)
local H = hit.Parent : FindFirstChild("Humanoid")
if H ~= nil then
SP.S:Play()
end
end
script.Parent.Touched:connect(onTouch)
local ready = true
local sound = script.Parent.Sound--Change to your sound location.
script.Parent.Touched:Connect(function()
if ready == true then
ready = false
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
end
sound:Stop()
sound:Play()
wait(2) -- Amount of till making smoke dissapear
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Smoke:Destroy()
end
ready = true
end
end)