Advertisement
RandomBlox47

Powerful Particle Emitter

Jun 6th, 2022
1,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. -- this script is an code sample from https://developer.roblox.com/en-us/api-reference/class/ParticleEmitter#:~:text=A%20ParticleEmitter%20allows%20for%20the%20creation%20of%20particle,a%20BillboardGui%20with%20a%20single%20ImageLabel%20in%20it. except it will execute in all players
  2. -- see more of my scripts in https://pastebin.com/u/RandomBlox47/1/zzkM755Y
  3. for i, Player in pairs(game.Players:GetPlayers()) do -- runs a script in all players
  4. local emitter = Instance.new("ParticleEmitter", Player.Character.PrimaryPart)
  5. -- Number of particles = Rate * Lifetime
  6. emitter.Rate = 5 -- Particles per second
  7. emitter.Lifetime = NumberRange.new(1,1) -- How long the particles should be alive (min, max)
  8. emitter.Enabled = true
  9.  
  10. -- Visual properties
  11. emitter.Texture = "rbxassetid://1266170131" -- A transparent image of a white ring
  12. -- For Color, build a ColorSequence using ColorSequenceKeypoint
  13. local colorKeypoints = {
  14.     -- API: ColorSequenceKeypoint.new(time, color)
  15.     ColorSequenceKeypoint.new( 0, Color3.new(1, 1, 1)),  -- At t=0, White
  16.     ColorSequenceKeypoint.new(.5, Color3.new(1, .5, 0)), -- At t=.5, Orange
  17.     ColorSequenceKeypoint.new( 1, Color3.new(1, 0, 0))   -- At t=1, Red
  18. }
  19. emitter.Color = ColorSequence.new(colorKeypoints)
  20. local numberKeypoints = {
  21.     -- API: NumberSequenceKeypoint.new(time, size, envelop)
  22.     NumberSequenceKeypoint.new( 0, 1);    -- At t=0, fully transparent
  23.     NumberSequenceKeypoint.new(.1, 0);    -- At t=.1, fully opaque
  24.     NumberSequenceKeypoint.new(.5, .25);  -- At t=.5, mostly opaque
  25.     NumberSequenceKeypoint.new( 1, 1);    -- At t=1, fully transparent
  26. }
  27. emitter.Transparency = NumberSequence.new(numberKeypoints)
  28. emitter.LightEmission = 1 -- When particles overlap, multiply their color to be brighter
  29. emitter.LightInfluence = 0 -- Don't be affected by world lighting
  30.  
  31. -- Speed properties
  32. emitter.EmissionDirection = Enum.NormalId.Front -- Emit forwards
  33. emitter.Speed = NumberRange.new(0, 0) -- Speed of zero
  34. emitter.Drag = 0 -- Apply no drag to particle motion
  35. emitter.VelocitySpread = NumberRange.new(0, 0)
  36. emitter.VelocityInheritance = 0 -- Don't inherit parent velocity
  37. emitter.Acceleration = Vector3.new(0, 0, 0)
  38. emitter.LockedToPart = false -- Don't lock the particles to the parent
  39. emitter.SpreadAngle = Vector2.new(0,0) -- No spread angle on either axis
  40.  
  41. -- Simulation properties
  42. local numberKeypoints2 = {
  43.     NumberSequenceKeypoint.new(0, 0);  -- At t=0, size of 0
  44.     NumberSequenceKeypoint.new(1, 10); -- At t=1, size of 10
  45. }
  46. emitter.Size = NumberSequence.new(numberKeypoints2)
  47. emitter.ZOffset = -1 -- Render slightly behind the actual position
  48. emitter.Rotation = NumberRange.new(0, 360) -- Start at random rotation
  49. emitter.RotSpeed = NumberRange.new(0) -- Do not rotate during simulation
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement