I am creating a blood script, and I need to use normals to get the blood to the right orientation of the raycast. But for some reason I can’t get it to get the right angle.
I’ve tried using free models to look for any examples, asked others, but didn’t help really. Just got an understanding of what it is.
Script:
game.Players.PlayerAdded:Connect(function(plr)
local Folder = Instance.new("Folder", game.Workspace)
Folder.Name = "BloodFolder"
plr.CharacterAdded:Connect(function(char)
print(char.Name)
local hum = char:FindFirstChildOfClass("Humanoid")
local oldHealth = hum.Health
hum.HealthChanged:Connect(function()
local humanoidRoot = char:WaitForChild("HumanoidRootPart")
local rayDirection = Vector3.new(math.random(-120, 120),math.random(-120, 120),math.random(-120, 120))
local raycastparams = RaycastParams.new()
raycastparams.FilterDescendantsInstances = {char, Folder:GetChildren()}
raycastparams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(humanoidRoot.Position, rayDirection, raycastparams)
--blood sizes
local size1 = Vector3.new(3, 0.34, 3)
local size2 = Vector3.new(5, 0.34, 5)
local size3 = Vector3.new(6.5, 0.34, 6.5)
local random = math.random(1,3)
if raycastResult then
local blood = game.ServerStorage.BloodPart:Clone()
local hitPart = raycastResult.Instance
blood.CFrame = CFrame.new(raycastResult.Position)
blood.CFrame = CFrame.lookAt(raycastResult.Normal,raycastResult.Normal,raycastResult.Normal)
blood.Parent = Folder
local tweenservice = game:GetService("TweenService")
-- create size with tweenservice
if random == 1 then
local info = TweenInfo.new(5,Enum.EasingStyle.Circular, Enum.EasingDirection.Out,0,false,0.1)
local goal = {Size = size1}
local expand = tweenservice:Create(blood,info,goal)
expand:Play()
end
if random == 2 then
local info2 = TweenInfo.new(5,Enum.EasingStyle.Circular, Enum.EasingDirection.Out,0,false,0.1)
local goal2 = {Size = size2}
local expand2 = tweenservice:Create(blood,info2,goal2)
expand2:Play()
end
if random == 3 then
local info3 = TweenInfo.new(5,Enum.EasingStyle.Circular, Enum.EasingDirection.Out,0,false,0.1)
local goal3 = {Size = size3}
local expand3 = tweenservice:Create(blood,info3,goal3)
expand3:Play()
end
end
end)
end)
end)
Yes, its kinda junky but it works. I just need the raycast normal for now :^)
Anything helps!