Source Code
--- BIack1st
local module = {}
local Blacklisted = {}
local CollisionsService = game:GetService("PhysicsService")
function module.new(StarterPart:Part, Particles:ParticleEmitter)
local function CheckGroups(Group1:string, Group2:string)
return CollisionsService:CollisionGroupsAreCollidable(Group1, Group2)
end
local GroupId = StarterPart.CollisionGroupId
local GroupName = CollisionsService:GetCollisionGroupName(GroupId)
local function GetDirection(Part:BasePart, Particles:ParticleEmitter)
local ParticleDirection = Particles.EmissionDirection
if ParticleDirection == Enum.NormalId.Top then
return Part.CFrame.UpVector
elseif ParticleDirection == Enum.NormalId.Back then
return -Part.CFrame.LookVector
elseif ParticleDirection == Enum.NormalId.Front then
return Part.CFrame.LookVector
elseif ParticleDirection == Enum.NormalId.Bottom then
return -Part.CFrame.UpVector
elseif ParticleDirection == Enum.NormalId.Left then
return -Part.CFrame.RightVector
elseif ParticleDirection == Enum.NormalId.Right then
return Part.CFrame.RightVector
end
end
local Direction = GetDirection(StarterPart, Particles)
local ResultRay = workspace:Raycast(StarterPart.Position, Direction * 5000)
if ResultRay then
local RayInstance = ResultRay.Instance
local Pos = ResultRay.Position
Particles.Lifetime = NumberRange.new((StarterPart.Position - Pos).Magnitude * (5.3 / Particles.Speed.Max / 2 ) / 2.75 )
else
Particles.Lifetime = NumberRange.new(math.huge)
end
end
return module
Download: Particle Collisions - Roblox
Hello, so yesterday I made this post. I decided that I’m going to make what I made into a module for anyone’s use! This module allows you to create particle collisions easily. So no more particles going through walls! This module supports, emission direction, speed, and rotation! Heres how it looks in action!
For Parts, If you want to use this with an attachment then look below
First of all, make sure you have the module installed. If you don’t have it, then download it here.
Once you’ve downloaded it. Go to toolbox → inventory and insert the module into replicated stroage.
If you already have a particle emitter then you can skip this part. After that, insert a particle emitter into your desired part. Customize however much you like.
Once you’re done customizing your particles. Insert a script into your part and type this. Make sure to edit the script to make it work in your situation.
local Module = require(game.ReplicatedStorage.ParticleCollisions)
Module.new(script.Parent, script.Parent.ParticleEmitter)
Making it repeat
Well, we finished doing the steps. The only issue is. It’ll calculate once. Which is a huge issue. Because if the part moves then it’ll give us in-accurate results. To fix this do:
game:GetService('RunService').Heartbeat:Connect(function()
local Module = require(game.ReplicatedStorage.ParticleCollisions)
Module.new(script.Parent, script.Parent.ParticleEmitter)
end)
Attachments
First of all, make sure you have the module installed. If you don’t have it, then download it here.
Once you’ve downloaded it. Go to toolbox → inventory and insert the module into replicated storage.
If you already have am attachment and particles then you can skip this part. After that, insert an attachment into your desired part. Then, insert a particle emitter into the attachment. Customize it to your liking.
After you finished customizing the particles, insert a script into the attachment. Once you’ve done that, type this into your script. Edit it to work in your situation.
game:GetService('RunService').Heartbeat:Connect(function()
local Module = require(game.ReplicatedStorage.ParticleCollisions)
Module.FromAttactment(script.Parent, script.Parent.ParticleEmitter)
end)
I hope this module will help you! If you find any bugs, have a suggestion, or have feedback then feel free to say below! I’m open to any criticism!