I want to make a permanent check for a part in another part. Can it somehow affect at optimization?
Example:
local plr = game.Players.LocalPlayer
local part = workspace.Part
game:GetService("RunService").RenderStepped:Connect(function()
local char = plr.Character
if char then
local hrp = char:findFirstChild("HumanoidRootPart")
if hrp then
local dist = (hrp.CFrame.p-part.CFrame.p).magnitude
if dist <= 4 then
print(dist)
end
end
end
end)

3 comments
RenderStepped should only be used for camera. You really, really should not have to check magnitude that often. But if you do (and you 100% sure you do), use heartbeat instead. It dosen't yield redering. Edit: It looks like your problem could be solved by touch event instead.
no RenderStepped can be used as long as its in a LocalScript; it can also influence the server by have it fire a remote event. But everything else u say is roughly agreeable
Hm, ok. Thank you. I will use heartbeat. And what I want to do unrelated with parts, it's true...