for some reason my splash is way off from were it hit, any help?
local part = script.Parent
local raycastDistance = 100
part.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then
local raycastResult = workspace:Raycast(part.Position, (hit.Position - part.Position).Unit * raycastDistance)
if raycastResult then
local hitPart = raycastResult.Instance
local hitCFrame = hitPart.CFrame
local randomnum = math.random(1, 3)
local splashpart = game.ReplicatedStorage.Splash:FindFirstChild("splash"..randomnum):Clone()
splashpart.Parent = workspace
local hitLookVector = hitCFrame.LookVector
local hitUpVector = Vector3.new(0, 1, 0) -- Set the up vector to point upwards
local hitRightVector = hitLookVector:Cross(hitUpVector)
splashpart.CFrame = CFrame.new(raycastResult.Position, raycastResult.Position + raycastResult.Normal)
splashpart.CFrame = splashpart.CFrame * CFrame.Angles(0, math.rad(90), 0)
splashpart.Color = script.Parent.Color
script.Parent:Destroy()
end
end
end)