Ive made the splat effects appear. but they dont face the position its shot from . I could use some help. I suck with Cframes
function SplatsModule.FireSplat(plr, pos, part, color, firePointPos, firePointCFrame, hitPos)
local keys = {}
for key in pairs(SplatsModule.Images) do
table.insert(keys, key)
end
local randomKey = keys[math.random(1, #keys)]
local randomImage = SplatsModule.Images[randomKey]
local splat = script.Splat:Clone()
splat.Parent = workspace.DebrisCache
splat.Decal.Color3 = color
--edit this around so it matches with your premade system
local exitPoint = firePointPos
local gunRange = 500
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {plr.Character} -- Ignore the player's character
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist -- Blacklist mode to ignore the specified instances
local direction = (pos - firePointPos).Unit * gunRange
local gunToShot = workspace:Raycast(exitPoint, direction, raycastParams)
if gunToShot then
local visualRay = Instance.new("Part")
visualRay.Size = Vector3.new(0.1, 0.1, (gunToShot.Position - exitPoint).Magnitude) -- Set the size based on the ray length
visualRay.CFrame = CFrame.new(exitPoint, gunToShot.Position) * CFrame.new(0, 0, -visualRay.Size.Z / 2) -- Position and rotate the part
visualRay.Anchored = true
visualRay.CanCollide = false
visualRay.BrickColor = BrickColor.new("Bright red")
visualRay.Material = Enum.Material.Neon
visualRay.Parent = workspace
splat.CFrame = CFrame.new(gunToShot.Position, gunToShot.Position + gunToShot.Normal)
local WeldConstraint = Instance.new("WeldConstraint", splat)
WeldConstraint.Part0 = splat
WeldConstraint.Part1 = gunToShot.Instance
goal.Size = Vector3.new(math.random() * 2 + 3, math.random() * 2 + 3, 0)
local tween = TweenService:Create(splat, tweenInfo, goal)
tween:Play()
end