Hello so i've ran into an issue. Whenever i loop a for loop, it creates enormous lag and delay. Is there any fix to this?
LocalScript:
--Example script, there might be errors since i just wrote this code.
while wait() do
for i,v in next, game:GetDescendants() do
if v:IsA("Instance") then
v.Changed:Connect(function(p)
game:GetService("ReplicatedStorage"):FindFirstChild("Prop", true):FireServer(v, tostring(p), v[tostring(p)])
end)
end
end
end
Simple. Incase if you dont understand, the localscript is supposed to get every object in game and detect if the property change.
ServerScript (Prop remote):
local PropRemote = game:GetService("ReplicatedStorage"):FindFirstChild("Prop") or false
PropRemote.OnServerEvent:Connect(function(plr, part, prop, value)
part[prop] = value
end)
NOTE: Yes i do know that i can do it from a serverscript without needing remote events.

3 comments
Pretty sure the while loop, will feel like it's not looping every 5 seconds instead of 6 I'd avoid using wait(), it's not accurate. but; "while wait(5) do"; should stop the lag for now
Use ipairs instead of next()
Didnt really fix it