-- Coroutines local ObjToMouse = coroutine.create(function(Obj) while true do if (Mouse.Target ~= CurrentObject) and (Client_Char.Torso.Position - Mouse.Hit.p).magnitude <=26 then wait(0.01) Obj.position = Mouse.Hit.p; print("Coroutine Running") end end end) local MaxCircP = coroutine.create(function(MaxC) while true do wait(0.01); MCBodyPos.position = Client_Char.Torso.Position+Vector3.new(0,-2.8,0); end end) -- Coroutines
Please tell me the problem if you can.
while true do
if (Mouse.Target ~= CurrentObject) and (Client_Char.Torso.Position - Mouse.Hit.p).magnitude <=26 then
05
wait(0.01)
06
Obj.position = Mouse.Hit.p;
07
print("Coroutine Running")
08
end
end
look closely at this loop. games crash when a loop runs infinitely without a wait.
sure, this loop has a wait, but that wait ONLY executes if Mouse.Target ~= CurrentObject, meaning that when it's false, the loop won't wait and crash the game.
fixing is easily done; put a wait() before the end of the while true do, like this:
while true do
if (Mouse.Target ~= CurrentObject) and (Client_Char.Torso.Position - Mouse.Hit.p).magnitude <=26 then
05
wait(0.01)
06
Obj.position = Mouse.Hit.p;
07
print("Coroutine Running")
08
end]
wait(1)
end
Locked by BlueTaslem
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?