Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Attempt to compare two userdata values?

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 !!!

2 comments

0

So just compare the Z components?

0

Yeah

1 answer

✓ Accepted answer

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.

2 comments

0

Actually figured this out myself but thanks anyways! :)

0

No problem :)

This discussion is preserved as it was. New answers, comments, and votes are closed.