local Bindable = Instance.new("BindableEvent")
Bindable.Event:Connect(function()
print("Hi")
wait(1)
Bindable:Fire()
end)
Bindable:Fire()
Is this a good way to avoid while loops?
local Bindable = Instance.new("BindableEvent")
Bindable.Event:Connect(function()
print("Hi")
wait(1)
Bindable:Fire()
end)
Bindable:Fire()
Is this a good way to avoid while loops?
How come you can’t use while loops in your script?
-Grayseon
Use run service using either render stepped or heartbeat. Here is a good video: Roblox: Task Scheduler & Avoiding Wait - YouTube
What you are doing seems to be a Recursive Function.
An example of this in Lua would be:
local RunService = game:GetService("RunService")
local function Loop()
RunService.Heartbeat:Wait()
print("Looping")
Loop()
end
Loop()
I don’t see a difference except maybe performance? Either way this method seems more tedious to achieve the same effect as
while print('Hi') or true do
wait(1)
end