Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local runservice = game:GetService("RunService")
- local rad = math.rad
- local twserv = game:GetService("TweenService")
- local m = {}
- m.CreateParticles = function(info)
- --if true then
- local castedparts = {}
- for i = 1, info["amount" or 1] do
- local randomising = info["random"] or tick()
- local prt = Instance.new("Part")
- local ignore = {unpack(info["ignore"]or{}), prt, workspace.Effects}
- prt.Color = info["color"] or Color3.new(1,1,1)
- prt.Material = info["material"] or Enum.Material.Neon
- if prt.Material == Enum.Material.Neon then
- local l = Instance.new("SurfaceLight")
- l.Color = prt.Color
- l.Angle = 180
- l.Brightness = 1
- l.Range = 6
- l.Shadows = true
- l.Face = "Front"
- l.Parent = prt
- end
- prt.Size = Vector3.new(1,1,1)
- local premesh = Instance.new("SpecialMesh")
- premesh.MeshType = Enum.MeshType.Cylinder
- premesh.Parent = prt
- prt.Transparency = info["transparency"] or 0
- prt.CanCollide = false
- prt.Anchored = true
- --prt.Shape = info["shape"] or Enum.PartType.Cylinder
- table.insert(ignore, prt)
- table.insert(castedparts, prt)
- if info.transperencyfadeout then
- local twi = {}
- twi.Transparency = 1
- local twinfo = TweenInfo.new(.98, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, .3)
- local tween = twserv:Create(prt, twinfo, twi)
- tween:Play()
- end
- prt.Parent = info["parent"] or workspace
- spawn(function()
- game.Debris:AddItem(prt, info["maxtime"] or 2)
- local doing = true
- delay(info["maxtime"]or 2, function()
- doing = false
- end)
- local bounces = 0
- --local startpos = info["start"]
- local lastpos = info["start"].p
- local lasttime = tick()
- local spread = info["spread"]*100
- local randomangles = Vector3.new(rad(math.random(-spread, spread)/100), rad(math.random(-spread, spread)/100), rad(math.random(-spread, spread)/100))
- local randomvel = math.random(info["velspread"][1]*100, info["velspread"][2]*100)/100
- local vel = (info["start"] * CFrame.Angles(randomangles.X, randomangles.Y, randomangles.Z)).lookVector*randomvel*info["vel"]
- while doing and ( bounces < (info["bounces"] or 3) ) and prt.Transparency <1 do
- runservice.Heartbeat:Wait()
- local dt = tick() - lasttime
- local mnusy = ( workspace.Gravity*dt*(info["gravitycounter"] or 1))
- vel = Vector3.new(vel.X, vel.Y-mnusy, vel.Z)
- vel = vel*(info.drag or .965)
- --print(vel.Y)
- local newpos = lastpos + vel*dt
- local d = (lastpos - newpos).magnitude
- --print(lastpos)
- local cf = CFrame.new(lastpos, newpos)
- local r = Ray.new(cf.p, cf.LookVector*(d))
- local obj, pos, normal, mat = workspace:FindPartOnRayWithIgnoreList(r, {unpack(ignore), unpack(castedparts), workspace.Effects})
- --print(obj)
- if obj then
- --print(obj:GetFullName())
- bounces = bounces +1
- local casted = (cf.LookVector - ( 2 * cf.LookVector:Dot(normal) * normal))
- local castedvel = vel.magnitude
- --print(1-bounces/info["bounces"])
- vel = CFrame.new(pos, pos+casted).lookVector *castedvel*(1-bounces/info["bounces"])
- end
- prt.CFrame = cf * CFrame.new(0, 0, -d/2) * CFrame.Angles(0, math.pi/2, 0)
- premesh.Scale = Vector3.new(d+info["size"].Z, info["size"].Y, info["size"].X)
- lastpos = newpos
- lasttime = tick()
- end
- if prt then
- prt:Destroy()
- end
- coroutine.yield()
- end)
- end
- --print("gae")
- return castedparts
- --else
- --return {}
- --end
- end
- return m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement