I’m trying to Raycast and place a part under the players’ characters, but i keep getting this weird side effect
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char}
local result = workspace:Raycast(char.PrimaryPart.Position,Vector3.new(0,-1,0)*5000,rayParams)
I may have a outcome you may like, where the part does go underneath my player, but I can only do this with the limited information you’ve provided.
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char} -- Exclude the player's character from the raycast
local rayOrigin = char.PrimaryPart.Position
local rayDirection = Vector3.new(0, -1, 0) -- Straight down
local rayDistance = 5000
local result = workspace:Raycast(rayOrigin, rayDirection * rayDistance, rayParams)
if result then
-- The ray hit something
local hitPosition = result.Position
-- Now, you can place a part or perform any other actions using hitPosition
local newPart = Instance.new("Part")
newPart.Position = hitPosition
newPart.Parent = workspace
else
-- The ray didn't hit anything
warn("Raycast didn't hit anything.")
end