Workspace:RayCast() not working

I want to make an ability for earth that will summon earth spikes from underneath, but for that I need to check if the character is standing on the ground using the Raycast, I have tried it many times but I don’t understand why, raycast is facing direction up and checking if part is above the player, but I want it to check if it’s under the player, I can’t find solution for a long time so I would appreciate help. Here’s the script:

				debounce.Value = true
				local prparams = RaycastParams.new()
				prparams.FilterType = Enum.RaycastFilterType.Exclude
				prparams.FilterDescendantsInstances = {
					character:GetChildren()
				}
				local prdir = (character:GetPivot() * CFrame.new(0, 3.25, 0)).Position
				local prr = workspace:Raycast(character["Right Leg"].Position, prdir, prparams)
				print(prr)
				wait(0.1)
				debounce.Value = false
				if prr ~= nil then
					--local earthspikes = game:GetService("ServerStorage").EarthSpikes:Clone()
					--earthspikes.Parent = workspace
					--earthspikes.CFrame = character:GetPivot() * CFrame.new(0, 5, -22.5)
					wait(0.1)
					debounce.Value = false
				end
2 Likes
(character:GetPivot() * CFrame.new(0, -3.25, 0))

?

1 Like

I’m trying to make the direction of raycast to face down, I tried using vector3 but it didn’t work so I tried using (character:GetPivot() * CFrame.new(0, 3.25, 0)).Position instead, it didn’t work either. I just tried everything and I don’t understand what’s wrong

I get whats wrong now. You are using GetPivot() so the direction is the whole position of the character.

use GetPivot().LookVector + Vector3.new(0,-3.25,0) instead

edit:
LookVector is a DIRECTION vector of where the cframe is looking at

1 Like

Oh my gosh thank you so much man I couldn’t do it for like an hour or two and yet the solution was so simple :pray:

1 Like

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