How to add a loop inside a function and break it in 2 secs?
Asked by
5 years ago Edited 5 years ago
I'm trying to add a while true do or repeat until loop inside this function but i also want to stop it in 2 seconds i know you can do somthing similar to a function for example
1 | touch = part.Touched:Connect( function () |
im trying to go for something like this but with a loop it's hard ;/
here's my attempt
01 | game.ReplicatedStorage:WaitForChild( "shocky" ).OnServerEvent:Connect( function (plr) |
02 | local s = script.s:Clone() |
04 | s.Parent = plr.Character.Head |
06 | repeat print ( "doing code" ) wait ( 1 ) n = n + 1 until n = = 2 |
but it wont work because the wait(1) is gonna destroy the wait() loop