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

Attempt to compare two userdata values?

Asked by
MiguRB 60
5 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

So I have defined local buildings succesfully to children of a folder but the problem I'm having is that a for i = 1,#buildings do loop goes through every building of the folders building[i] and I'm trying to compare the CFrame of the building[i] and the CFrame of the player's HumanoidRootPart. The CFrame of the building[i] should be smaller than HumanoidRootPart.CFrame * CFrame.new(0,0,-10). So the Z part of the CFrame of the building[i] should be smaller.

But the thing what I'm trying to do is that it checks is the building[i] behind or in front of the player's HumanoidRootPart.

Help highly appreciated !!!

0
So just compare the Z components? User#6546 35 — 5y
0
Yeah MiguRB 60 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

something like this should work:

if buildings[i].Position.Z > HumanoidRootPart.Position.Z then
    print'in front'
else
    print'behind'
end

however, that is not the best way to do that.

0
Actually figured this out myself but thanks anyways! :) MiguRB 60 — 5y
0
No problem :) Internal_1 344 — 5y
Ad

Answer this question