Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------
- -- Furry Framework --
- ---------------------
- local Furry = _G.Furry
- ---------------------
- -- Roblox Services --
- ---------------------
- local RunService = Furry:GetService("RunService")
- -------------
- -- Remotes --
- -------------
- local ProjectileCreationRequest = Furry:CreateRemote("Remotes/Game/Projectiles/", "Request", "RemoteEvent")
- local ProjectileCreatedEvent = Furry:CreateRemote("Remotes/Game/Projectiles/", "Created", "RemoteEvent")
- local Projectiles = {
- Active = {},
- Inactive = {},
- }
- local function CreateProjectile(Owner, Type, Speed, Damage, Origin, Direction, IgnoreList)
- local Projectile
- if #Projectiles.Inactive < 1 then
- local Identity = "Projectile_"..tostring(tick())
- Projectile = {
- [1] = Identity,
- [2] = Owner,
- [3] = Type,
- [4] = Speed,
- [5] = Damage,
- [6] = Origin,
- [7] = Direction,
- [8] = IgnoreList,
- [9] = tick(), -- Activated
- Part = Furry:Create("Part", {
- Name = "Tracer",
- Anchored = true,
- CanCollide = false,
- BrickColor = BrickColor.new("Brick yellow"),
- Material = Enum.Material.Neon,
- Size = Vector3.new(0.3,0.3,4),
- Parent = game.Workspace.RayIgnore,
- })
- }
- else
- local Projectileindex = #Projectiles.Inactive
- Projectile = {
- [1] = Projectiles.Inactive[Projectileindex][1],
- [2] = Owner,
- [3] = Type,
- [4] = Speed,
- [5] = Damage,
- [6] = Origin,
- [7] = Direction,
- [8] = IgnoreList,
- [9] = tick(), -- Activated
- Part = Projectiles.Inactive[Projectileindex].Part,
- }
- table.remove(Projectiles.Inactive, Projectileindex)
- end
- Projectile.Part.BrickColor = BrickColor.new("Brick yelllow")
- Projectile.Part.CFrame = CFrame.new(Origin, Origin + Direction)
- Projectiles.Active[#Projectiles.Active+1] = Projectile
- ProjectileCreatedEvent:FireAllClients(Projectile)
- end
- ProjectileCreationRequest.OnServerEvent:connect(function(Player, Origin, Direction)
- local Owner = Player -- Will not always be Player
- local Type = nil -- Will be "Bullet" or "missile" or "Something else" in the future.
- local Speed = 80
- local Damage = 0
- local IgnoreList = {game.Workspace.RayIgnore, Player.Character}
- CreateProjectile(Owner, Type, Speed, Damage, Origin, Direction, IgnoreList)
- end)
- local Loop = coroutine.wrap(function()
- local Heartbeat = 0
- while true do
- Heartbeat = RunService.Heartbeat:wait()
- for Index = #Projectiles.Active, 1, -1 do
- local Projectile = Projectiles.Active[Index]
- local ProjectileSpeed = Projectile[4]
- local RayOrigin = Projectile[6]
- local Direction = Projectile[7]
- local TimeElasped = tick() - Projectile[9]
- if TimeElasped < 5 then
- --local DistanceTraveled = ProjectileSpeed * TimeElasped
- --local RayOrigin = CFrame.new(Origin, Origin + Direction) * Vector3.new(0,0, -DistanceTraveled)
- local RayLength = ProjectileSpeed * Heartbeat
- local Velocity = Direction * RayLength
- local IgnoreList = Projectile[8]
- local Hit, Position, Surface = Furry:RaycastWithIgnoreList(RayOrigin, Velocity, IgnoreList)
- if Hit then
- Projectile.Part.BrickColor = BrickColor.new("Shamrock")
- table.remove(Projectiles.Active, Index)
- Projectiles.Inactive[#Projectiles.Inactive+1] = Projectile
- end
- Projectile[6] = Position
- Projectile.Part.CFrame = CFrame.new(Position, Position + Direction)
- else
- Projectile.Part.BrickColor = BrickColor.new("Bright red")
- table.remove(Projectiles.Active, Index)
- Projectiles.Inactive[#Projectiles.Inactive+1] = Projectile
- end
- end
- end
- end)
- Loop()
- return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement