How to make splash effect like big paintball

how would I go about making when i shoot my paintball my splash part orientates exactly like in the video

local SplatsModule = {
	Images = {
		Splat1 = "http://www.roblox.com/asset/?id=18876066213",
		Splat2 = "http://www.roblox.com/asset/?id=18876056029",
		Splat3 = "http://www.roblox.com/asset/?id=18876063958",
		Splat4 = "http://www.roblox.com/asset/?id=18876060351",
	}	
}

function SplatsModule.FireSplat(plr, pos, part, color)
	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.Size = Vector3.new(math.random() * 2 + 3, math.random() * 2 + 3, 0)
	splat.WeldConstraint.Part1 = part

	local debugPart = Instance.new("Part", workspace)
	debugPart.Position = pos
	debugPart.Name = tostring(time())
	debugPart.Size = Vector3.new(1, 1, 1)
	debugPart.Color = Color3.fromRGB(85, 255, 0)
	debugPart.Material = Enum.Material.Neon
	debugPart.Anchored = true
	debugPart.CanCollide = false
	
	splat.Decal.Color3 = color


end




return SplatsModule

For the splash effect we would want to cast a raycast from the gun to the mouse.Hit position and then take the raycasts position and normal and subtract them together to get the effect of splash. We also need to orientation it so we could something like this:

--edit this around so it matches with your premade system
local gun = workspace.Gun
local exitPoint = gun.ExitPoint
local gunRange = 50
local gunToShot = workspace:Raycast(exitPoint.Position,exitPoint.Position+exitPoint.LookVector*gunRange)

if gunToShot then
	debugPart.CFrame = CFrame.lookAt(
		gunToShot.Position,
		gunToShot.Position-gunToShot.Normal,
		Vector3.FromNormalId(Enum.NormalId.Top)
	)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.