This has been a problem all day, originally it was lagging the server like crazy so i made it client based, but now its lagging the client!
I dont think theres a memory leak, really i have no idea what it is
local rs = game:GetService('RunService')
local humanoidRootPart = script.Parent.HumanoidRootPart -- startercharacterscript
local player = game.Players.LocalPlayer
while wait(0.1) do
local inafeild = false
local currentfeild = player.Values.Feild.Value -- stringvalue
local box = workspace[currentfeild..'Box'] -- hitbox for a feild, just a normal big part
if table.find(workspace:GetPartBoundsInBox(box.CFrame, box.Size), humanoidRootPart) then
inafeild = true
end
if player.Values.InFeild.Value ~= inafeild then
game.ReplicatedStorage.events.FeildClientToServer:FireServer(inafeild)
end
end