How could i fuse this 2 scripts into one

Hi so my problem is that i want this two scripts to work in one but it doesnt work:

--code 1 example

local flashlight = ...

while true do
--code
end
--code 2 
local run = game:GetService("RunService")
local char = script.Parent
run.Heartbeat:Connect(function()
--code
end)

how would i fuse this two into one code?

2 Likes

if you put the code 2 before the code 1 or use task.spawn

2 Likes

why do you need to put it in one script??
well if you need to then dont use task.spawn() because: the more threads then more lags on server
just put code 2 before code 1 so code 1 doesn’t yield thread with while loop

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.