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

How to delay a function? Easy? not use wait()

so I made this door script that plays a sound when its moving and when its closed

I want to make it so when the door closes it makes a "Thud" sound, but I need to delay the thud sound by 1 second because it plays too early

function open()
			local finish = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
			sound:Play()
			click:Destroy()
			thud:Play() -- how to make this play 1 second later?
				for i = 0,1,.01 do
					local cfm = script.Parent.PrimaryPart.CFrame:lerp(finish,i)
					script.Parent:SetPrimaryPartCFrame(cfm)
				wait()
			end
			wait(1)
			script:Destroy()
end

Make the thud sound play 1 second later without stopping the script. That is without adding a "Wait()" function.

1 comment

0

Try using a Co routine

1 answer

Nevermind found the answer myself

delay(.8,function()
            thud:Play()
            end)

3 comments

0

dang I was about to answer with that ;c

0

u should just use coroutinebut ok

0

coroutines are only used if you're planning to implement another script within a script.

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