I’m not very good at math, so I am trying to make the direction my blood is squirting relative to the direction the character is facing. Right now it can only go one direction which is this:
(It’s spewing out of a attachment)
Here is the part of the script:
local rayDirection = Vector3.new(math.random(-200,200), -workspace.Gravity, -math.random(200,400))
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character, workspace.Blood}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)```
For now, I would just experiment with some of the values in the rayDirection and see which ones work for the character. I’ve not used raycasts in a while so I can’t really help that much.
local rayOrigin = script.Parent.WorldPosition
local rayDirection = Vector3.new(math.random(-200,200), -workspace.Gravity, -math.random(200,400))
if Torso.Orientation.Y > -60 and Torso.Orientation.Y < -120 then
rayDirection = Vector3.new(math.random(-200,200), -workspace.Gravity, -math.random(200,400))
elseif Torso.Orientation.Y < -60 and Torso.Orientation.Y > -120 then
rayDirection = Vector3.new(-math.random(200,400), -workspace.Gravity, math.random(-200,200))
end
I think you could use -HumanoidRootPart.CFrame.RightVector*math.random(200,400)-Vector3.new(0,workspace.Gravity,0)+HumanoidRootPart.CFrame.LookVector*math.random(-200,200) as the ray direction
Instead of using torso, I would recommend using the HumanoidRootPart as that is the pirnary part of any character and EVERY charactee has one. Also using the humanoid root part’s front face can be used to determine the front of a character.
you can use
HumanoidRootPart.CFrame.LookVector to get the front side of the HRP
So like spawn the blood for example 5 studs from the HRP front face, which is the same as the front of the player’s character.