hello im trying to see if a value goes to empty to something but the problem is that when its going to true, my roblox studio freezes and " Script timeout: exhausted allowed execution time". I put a condition that stopped it but it still prints it.
while true do
if script.Parent.isInMatch.Value == false then
wait(0.25)
print("Test")
if script.Parent.PlayerOne.Value ~= "" then
script.Parent.isInMatch.Value = true
print("On")
end
end
end
i put it after the condition to not cause lag. since there is gonna be like 9 times this code running at the same time. It wont cause lag right? If so, how can i remove it
It is better to use Runservice for situations like this, as while true loops aren’t as good
for example
local runservice = game:GetService("RunService")
local In_match = script.Parent:WaitForChild("isInMatch")
runservice.Heartbeat:Connect(function()
if In_match.Value == false then
task.wait(.25)
print("Test")
if script.Parent.PlayerOne.Value ~= "" then
In_match.Value = true
print('On')
end
end
end)