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

How to lag efficiently check if another part is above my part?

Asked by
Derzett 51
4 years ago

So basically i already made a solution for that with the problem being.. It's REALLY laggy.

And i kind of understand why it does that but it's the only solution i know of.

Example of what i'm using:

for _,v in pairs(workspace:GetChildren()) do
if v:IsA("BasePart") then
if (v.Position - MyPart.Position + Vector3.new(0,2,0)).Magnitude < 5 then
myfunction()
end
end
end

now it does work but like i said it's very laggy!

I've been thinking about using rays but i'm new to them since i never bothered trying them out in any of my scripts but i think they can stop at certain points when they hit a part if you use the right script.

Any ideas on how i could fix this?

2 answers

Log in to vote
2
Answered by
Radstar1 270 Moderation Voter
4 years ago

Constantly fire a ray that shoots above the parts position.

local newray = Ray.new(MyPart.Position, MyPart.Position + Vector3.new(0,999,0) local Hit,Position = workspace:FindPartOnRay(newray) print(Hit) you can use FindPartOnRayWithIgnoreList to filter out what you want it to hit.

Ad
Log in to vote
0
Answered by 4 years ago

Add a wait(). hope it helps!

Answer this question