The map's height rises at a point and descends at another. It is bigger than 5 max sized baseplates. Is there any way to check the player's distance in the y position from the actual map?
✓ ANSWER ACCEPTED
Is there a script to check for player's y position distance from a map?
1 answer
✓ Accepted answer
From what I'm guessing I think you are saying you have like a map with varying heights like hills and stuff and you want to know how far the character is from the point on the map below them. To get that you would have to use raycast. Its pretty simple but if you only want to decect the map you would have to group the map into one model if its not terrain. Your script would look something like this:
local map = workspace.Map -- holds the map you want to check the height from
function GetHeightRelativeToMap(character)
local HumanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local startPoint = HumanoidRootPart.CFrame.p
local Direction = Vector3.new(0,-1,0) * 300 -- anything greater than like 600 might cause lag.
local DownRay = Ray.new(startPoint,Direction)
local hit,Position = workspace:FindPartOnRayWithWhiteList(DownRay,{map,workspace.Terrain}) -- if you only wanted to use terrain don't include the map in the whitelist table.
if hit then
return HumanoidRootPart.Position.Y - Position.Y
else
-- no map underneath the player so return nothing or maybe like math.huge or maybe just there y position
return HumanoidRootPart.Position.Y
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'm confused on what you're trying to do but you could just subtract the player's y position from whatever to check or use Magnitude to get the distance but it won't only be on the y axis.