How can I use Runservice.Heartbeat to se if a Players Character is in a part?

How can I use Runservice.Heartbeat to se if a Players Character is in a part?

RunService.Heartbeat as far as I’m aware of is the exact same as while task.wait() do

A Simple way would be:

while true do -- Random loop (CHange it if you like)
    if Part then -- If Part Exists
    end

    RunService.Heartbeat:Wait() -- or task.wait()
end

To Check within Descendants or to Find the First Instance, Use FindFirstChild

Instance:FindFirstChild("Example", true) -- looks through Descendants
Instance:FindFirstChild("Example") -- does not look through Descendants

This would cause A LOT Of lag. You should NOT combine two looping functions together.

I have tested, it does not

Inside the Heartbeat event handler:

  • call GetPartsInPart on the character’s HumanoidRootPart
  • loop through the result and see if your zone part is in the list
1 Like

RunService.Heartbeat:Wait() returns a number.

What are you talking about?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.