Downslam script not functioning properly

Hello, I am working on a combat system with a friend. I am currently working on a air combo finisher that slams them into the ground.

It uses raycasts to detect the ground that the target is going to be positioned to, and sets the targets position to the raycast result. Here is how I want it to work.

Blue: Starting Position/Main Player
Red: Direction I want the ray to go
Orange: Ending position/where the target will go

image

But this is happening.

the raycast goes straight down instead of infront of the player and down. Any idea how to fix this? Thanks a lot!

CODE:

local ray = workspace:Raycast(char.HumanoidRootPart.Position,Vector3.new(-char.HumanoidRootPart.CFrame.lookVector * 500,-100,0),rParams)
1 Like

When you used

-char.HumanoidRootPart.CFrame.lookVector * 500

as the X value of your Vector3, it is being defaulted to 0 because it’s not a number, it’s a Vector3 of it’s own.

Try this:

local ray = workspace:Raycast(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector * 500, rParams)

EDIT:
To add your downward angle try this. You can change the -45 to the angle you want.

local ray = workspace:Raycast(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame + (char.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(-45), 0, 0)).LookVector * 100, rParams)
1 Like
local ray = workspace:Raycast(0, -100, char.HumanoidRootPart.CFrame:VectorToObjectSpace(Vector3.new(0, 0, -25)).Z),rParams)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.