Parkour system help

Hello, i’m making a parkour system and it was working pretty well untill i ran into a problem i don’t know how to fix.


I believe this happens because i’m using the size so it’ll be different depending on rotation.

Anyways, here’s my code.

    local RayPos = ray.Position
	local RayInstance = ray.Instance
	local Pos1 = RayPos
	local Y = RayInstance.Position.Y + RayInstance.Size.Y/2
	local Size = RayInstance.Size
	local MaxCF = RayInstance.CFrame * CFrame.new(Size.X/2,Size.Y/2,Size.Z/2)
	local MinCF = RayInstance.CFrame * CFrame.new(-Size.X/2,Size.Y/2,-Size.Z/2)
	local Pos2 = Vector3.new(math.clamp(RayPos.X,MinCF.X,MaxCF.X),Y,math.clamp(RayPos.Z,MinCF.Z,MaxCF.Z))
	local Brick = Instance.new("Part")
	Brick.Anchored = true
	Brick.CanCollide = false
	Brick.Color = Color3.new(1, 0, 0)
	Brick.Size = Vector3.new(0.2,0.2,0.2)
	Brick.Position = Pos2
	Brick.Parent = workspace

Anyone know how i can fix this?

1 Like

Can you elaborate on what it is that the system is supposed to do?

Well, it’s supposed to find the corners of the part so i can restrain the rayposition, and then create a way for the character to climb up when they’re close to a ledge.


This drawing is horrible, but hopefully you’ll understand what i mean.

You don’t have to find it, you can just put a block to it’s corners and you can use magnitude

And the error is probably because max is smaller than the min.

Can I see line 54 on the main local script, because that’s where the error is coming from. However I can guess that you have put the Max value lower than the Min value therefore creating an error. And I’m assuming that if you rotate a part this can make the error

Yes, that’s the problem. I’m not sure as to what i should do since i have to find the Max X coordinate inside the part and the Max Z coordinate, and vice verse.

local Pos2 = Vector3.new(math.clamp(RayPos.X,MinCF.X,MaxCF.X),Y,math.clamp(RayPos.Z,MinCF.Z,MaxCF.Z))

Have you placed them correctly into the ()?

Yes, it’s because of the rotation. I believe i might have to use the lookvectors of the part to correctly find it, although i’m unsure.

Can I see how you are getting the max and min and x

local MaxCF = RayInstance.CFrame * CFrame.new(Size.X/2,Size.Y/2,Size.Z/2)
local MinCF = RayInstance.CFrame * CFrame.new(-Size.X/2,Size.Y/2,-Size.Z/2)

I’m not familiar with Rays, however you will probably have to also calculate the rotation of the part and then calculate that into the rayinstance

if MinCF.X > MaxCF.X and MinCF.Z < MaxCF.Z then
					Pos2 = Vector3.new(math.clamp(RayPos.X,MaxCF.X,MinCF.X),Y,math.clamp(RayPos.Z,MinCF.Z,MaxCF.Z))
				elseif MinCF.Z > MaxCF.Z and MinCF.X < MaxCF.X then
					Pos2 = Vector3.new(math.clamp(RayPos.X,MinCF.X,MaxCF.X),Y,math.clamp(RayPos.Z,MaxCF.Z,MinCF.Z))
				elseif MinCF.Z > MaxCF.Z and MinCF.X > MaxCF.X then
					Pos2 = Vector3.new(math.clamp(RayPos.X,MaxCF.X,MinCF.X),Y,math.clamp(RayPos.Z,MaxCF.Z,MinCF.Z))
				else
					Pos2 = Vector3.new(math.clamp(RayPos.X,MinCF.X,MaxCF.X),Y,math.clamp(RayPos.Z,MinCF.Z,MaxCF.Z))
				end

Ended up on this, it works but i feel it might error in a specific condition.

1 Like

Also, CFrames already do that. It was just because at a specific rotation the X,'s or Z’s would be flipped, causing one of them to be more than the max.

1 Like

your parkour system is very nice I was wondering what type of game you’re making and if the parkour system is going to be released on #resources:community-resources?

I might release it but it’s being used for a game currently