Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

It's a normal situation for optimization in my game?

Asked by
Shaehl -11
5 years ago

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)
0
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. sleazel 1287 — 5y
0
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 TheluaBanana 946 — 5y
0
Hm, ok. Thank you. I will use heartbeat. And what I want to do unrelated with parts, it's true... Shaehl -11 — 5y

Answer this question