Skip to content

Instantly share code, notes, and snippets.

Created January 14, 2018 21:40
Show Gist options
  • Save anonymous/1f466228fd880e689f275833a6a32b9a to your computer and use it in GitHub Desktop.
Save anonymous/1f466228fd880e689f275833a6a32b9a to your computer and use it in GitHub Desktop.
GunScripts, AI and GameServer
return function()
--[[
Basic Monster by ArceusInator
Information:
Configurations.MaximumDetectionDistance (default 200)
The monster will not detect players past this point. If you set it to a negative number then the monster will be able to chase from any distance.
Configurations.CanGiveUp (default true)
If true, the monster will give up if its target goes past the MaximumDetectionDistance. This is a pretty good idea if you have people teleporting around.
Configurations.CanRespawn (default true)
If true, the monster will respawn after it dies
Configurations.AutoDetectSpawnPoint (default true)
If true, the spawn point will be auto detected based on where the monster is when it starts
Configurations.SpawnPoint (default 0,0,0)
If Settings.AutoDetectSpawnPoint is disabled, this will be set to the monster's initial position. This value will be used when the monster auto respawns to tell it where to spawn next.
Configurations.FriendlyTeam (default Really black)
The monster will not attack players on this team
Mind.CurrentTargetHumanoid (Humanoid objects only)
You can force the monster to follow a certain humanoid by setting this to that humanoid
Monster.Respawn (Function)
Arguments are: Vector3 point
Info: Respawns the monster at the given point, or at the SpawnPoint setting if none if provided
Monster.Died (Event)
Info: Fired when the monster dies
Monster.Respawned (Event)
Info: Fired when the monster respawns
--]]
local Self = script.Parent
local FindFirstChild = game.FindFirstChild
local Bot = require(Self.BOT)
local Target = nil
local RAY = Ray.new
local CF = CFrame.new
local RANDOM = math.random
local HUGE = math.huge
local TICK = tick
local RayCast = workspace.FindPartOnRayWithIgnoreList
local Weapon = Self.CurrentItem.Value
Self.CurrentItem.Changed:connect(function(item)
Weapon = item
end)
local bindableService = require(game.ReplicatedStorage.BindingService)()
local MobService = require(game.ServerScriptService.MobFunctions);
local Info = {
-- These are constant values. Don't change them unless you know what you're doing.
-- Advanced settings
RecomputePathFrequency = 1, -- The monster will recompute its path this many times per second
RespawnWaitTime = 5, -- How long to wait before the monster respawns
JumpCheckFrequency = 1, -- How many times per second it will do a jump check
}
local Pathfinder = MobService.Pathfinder.new(Self.PrimaryPart,Self.Human,Self);
local Data = {
-- These are variable values used internally by the script. Advanced users only.
LastRecomputePath = 0,
Recomputing = false, -- Reocmputing occurs async, meaning this script will still run while it's happening. This variable will prevent the script from running two recomputes at once.
CurrentNode = nil,
CurrentNodeIndex = 1,
AutoRecompute = true,
LastJumpCheck = 0,
LastAttack = 0,
AttackTrack = nil,
}
--
--
local Monster = {} -- Create the monster class
function Monster:GetCFrame()
-- Returns the CFrame of the monster's humanoidrootpart
local humanoidRootPart = FindFirstChild(Self,'Torso')
if humanoidRootPart ~= nil and humanoidRootPart:IsA('BasePart') then
return humanoidRootPart.CFrame
else
return CF()
end
end
function Monster:GetMaximumDetectionDistance()
-- Returns the maximum detection distance
local setting = Bot.ChaseRange
if setting < 0 then
return HUGE
else
return setting
end
end
function Monster:GetTargetCFrame()
local targetHumanoid = Target
if Monster:TargetIsValid() then
if targetHumanoid.Parent.PrimaryPart then
return targetHumanoid.Parent.PrimaryPart.CFrame
else
return CF()
end
else
return CF()
end
end
function Monster:IsAlive()
return Self.Human.Health > 0 and Self.Human.Torso ~= nil
end
function Monster:GetClosestEnemies()
local result = {}
local enemyAIs = workspace.Mobs:GetChildren()
-- local Tanks = workspace.Tanks:GetChildren()
local enemyPlayers = bindableService.fetch("PlayerList")
for i, enemy in next, enemyAIs, nil do
if enemy then
if enemy:FindFirstChildOfClass("Humanoid") then
if require(enemy.BOT).Allegiance ~= Bot.Allegiance and enemy.PrimaryPart then
local distance = (enemy.PrimaryPart.CFrame.p - Monster:GetCFrame().p).magnitude
if distance < Monster:GetMaximumDetectionDistance() then
result[#result+1] = enemy
end
end
end
end
end
-- for i, enemy in next, Tanks, nil do
-- if enemy then
-- if enemy:FindFirstChild("Human") then
-- if require(enemy.BOT).Allegiance ~= Bot.Allegiance and enemy.PrimaryPart then
-- local distance = (enemy.PrimaryPart.CFrame.p - Monster:GetCFrame().p).magnitude
-- if distance < Monster:GetMaximumDetectionDistance() then
-- result[#result+1] = enemy
-- end
-- end
-- end
-- end
-- end
for i, enemy in next, enemyPlayers, nil do
if enemy then
if enemy.Character then
if enemy.Character:FindFirstChildOfClass("Humanoid") then
if enemy.Allegiance.Value ~= Bot.Allegiance then
if enemy.Character.PrimaryPart then
local distance = (enemy.Character.PrimaryPart.CFrame.p - Monster:GetCFrame().p).magnitude
if distance < Monster:GetMaximumDetectionDistance() then
local squadMates = enemy.playerArmy.Value:GetChildren()
for j, secondEnemy in next, squadMates, nil do
if secondEnemy:FindFirstChildOfClass("Humanoid") and secondEnemy.PrimaryPart then
local distance = (secondEnemy.PrimaryPart.CFrame.p - Monster:GetCFrame().p).magnitude
if distance < Monster:GetMaximumDetectionDistance() then
result[#result+1] = secondEnemy
end
end
end
end
end
end
end
end
end
end
return result
end
function Monster:SearchForTarget(randomized)
-- Finds the closest player and sets the target
local npcs = Monster:GetClosestEnemies()
local closestCharacter, closestCharacterDistance
if not randomized then
for i, npc in next, npcs, nil do
local npcBOT = require(npc.BOT)
if npcBOT.Allegiance ~= Bot.Allegiance then
if npc ~= nil and npc.PrimaryPart and npc:FindFirstChild('Human') ~= nil and (npc.Human:IsA('Humanoid') or npc:FindFirstChild("TankManager")) then
local distance = (npc.PrimaryPart.CFrame.p - Monster:GetCFrame().p).magnitude
if distance < Monster:GetMaximumDetectionDistance() then
if closestCharacter == nil then
closestCharacter, closestCharacterDistance = npc, distance
else
if closestCharacterDistance > distance then
closestCharacter, closestCharacterDistance = npc, distance
end
end
end
end
end
end
local players = bindableService.fetch("PlayerList")
for i, player in next, players, nil do
if player.Allegiance.Value ~= Bot.Allegiance then
local character = player.Character
if character ~= nil and character.PrimaryPart and character:FindFirstChild('Humanoid') ~= nil and character.Humanoid:IsA('Humanoid') then
local distance = (character.PrimaryPart.CFrame.p - Monster:GetCFrame().p).magnitude
if distance < Monster:GetMaximumDetectionDistance() then
if closestCharacter == nil then
closestCharacter, closestCharacterDistance = character, distance
else
if closestCharacterDistance > distance then
closestCharacter, closestCharacterDistance = character, distance
end
end
end
end
end
end
else
closestCharacter = npcs[RANDOM(1,#npcs)]
end
if closestCharacter ~= nil then
Target = closestCharacter:FindFirstChildOfClass("Humanoid")
end
end
function Monster:IsReachable(point)
local PathFS = game:GetService("PathfindingService")
local Path = PathFS:FindPathAsync(Monster:GetCFrame().p,point.CFrame.p)
return Path.Status == Enum.PathStatus.Success
end
function Monster:IsReachableCFrame(point)
local PathFS = game:GetService("PathfindingService")
local Path = PathFS:FindPathAsync(Monster:GetCFrame().p,point.p)
return Path.Status == Enum.PathStatus.Success
end
function Monster:GetPatrollingPoint ()
local points = {}
local result = nil
local PatrollingPoints = bindableService.fetch("GetPatrolPoints")
for _, point in pairs(PatrollingPoints) do
if Monster:IsReachableCFrame(point) then
points[#points+1] = point
end
end
if #points > 0 then
result = points[math.random(#points)]
end
return result
end
local GrenadeThrow = true
Self.Human.Running:connect(function(Speed)
if Speed > 0 and Weapon then
Weapon.TargetCFrame.Value = CFrame.new(Self.Head.CFrame.p + (((Self.Human.WalkToPoint - Self.Head.CFrame.p).unit * Vector3.new(1,0,1)) * 200))
end
end)
function Monster:Update()
if math.random(1,16) == 16 then
local PatrolPoint = Monster:GetPatrollingPoint()
if PatrolPoint then
Pathfinder.Target = PatrolPoint.p
local status = Pathfinder:ComputePath(true)
if status == Enum.PathStatus.Success then
Self.Human.WalkSpeed = 25
Pathfinder:Start(1,function()
Monster:SearchForTarget(false)
end)
repeat wait() until Pathfinder.Stopped:wait() or Target ~= nil
end
end
end
Monster:SearchForTarget(false)
if Monster:TargetIsValid() then
Pathfinder.Target = Monster:GetTargetCFrame().p
local Distance = (Monster:GetTargetCFrame().p - Monster:GetCFrame().p).magnitude
local status = Pathfinder:ComputePath(false)
if status == Enum.PathStatus.Success then
Self.Human.WalkSpeed = 25
Pathfinder:Start(1,function()
if Monster:TargetIsValid() and (((Monster:GetTargetCFrame().p - Monster:GetCFrame().p).magnitude <= 60)) and Monster:HasClearLineOfSight() then
Self.SightedEnemy.Value = true
Self.Shooting.Value = true
Self.Human.WalkSpeed = 0
Pathfinder:Stop("EnemySighted")
Self.SetAimed:Fire(true)
spawn(function()
if math.random(1,16) == 16 and GrenadeThrow then
GrenadeThrow = false
Self.Shooting.Value = false
Weapon.throwGrenade:Fire(1)
Self.Shooting.Value = true
wait(32)
GrenadeThrow = true
end
end)
repeat
Weapon.TargetCFrame.Value = Monster:GetTargetCFrame()
wait()
until
(not Monster:IsAlive()) or (not Monster:HasClearLineOfSight()) or (not Monster:TargetIsValid()) or (Monster:GetTargetCFrame().p - Monster:GetCFrame().p).magnitude > 60
Self.SetAimed:Fire(false)
Self.Human.WalkSpeed = 25
Self.Shooting.Value = false
Self.SightedEnemy.Value = false
end
end)
end
end
end
function Monster:UpdateSniper()
Monster:SearchForTarget(false)
if Monster:TargetIsValid() then
local Distance = (Monster:GetTargetCFrame().p - Monster:GetCFrame().p).magnitude
if Monster:HasClearLineOfSight() then
Self.SetAimed:Fire(true)
Self.SightedEnemy.Value = true
repeat
Weapon.TargetCFrame.Value = Monster:GetTargetCFrame()
wait()
until
Self.Human.Health <= 0 or Monster:HasClearLineOfSight() or (Monster:GetTargetCFrame().p - Monster:GetCFrame().p).magnitude > Monster:GetMaximumDetectionDistance()
if Monster:HasClearLineOfSight() then
Weapon.Activate:Fire()
wait(2)
end
Self.SetAimed:Fire(false)
Self.SightedEnemy.Value = false
end
end
end
function Monster:TargetIsValid()
local targetHumanoid = Target
if targetHumanoid and targetHumanoid:IsA 'Humanoid' and not targetHumanoid:IsDescendantOf(workspace.CorpseIgnore) and targetHumanoid.Parent then
return true
else
return false
end
end
function Monster:HasClearLineOfSight()
-- Going to cast a ray to see if I can just see my target
local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
local hit, pos = RayCast(workspace,
RAY(
myPos,
targetPos - myPos
),
{
Self
}
)
return hit ~= nil and hit:IsDescendantOf(Target.Parent)
end
function Monster:Initialize()
Self.GetTarget.OnInvoke = function()
return Target
end
Self.SetTarget.Event:connect(function(target)
Target = target
end)
end
function Monster:InitializeUnique()
if Bot.Role == "Sniper" then
Weapon.ChangeStance:Fire("Prone")
end
end
--
--
Monster:Initialize()
Monster:InitializeUnique()
while Self.Human.Health > 0 do
if not Monster:IsAlive() then
break
end
if Monster:IsAlive() then
if Bot.Role == "Sniper" then
Monster:UpdateSniper()
else
Monster:Update()
end
repeat wait() until (not Self.SightedEnemy.Value)
end
wait()
end
end
---- Retouched Core RPG Script
local Connections = {}
local AnalyticsService = require(game.ReplicatedStorage.AnalyticsService)
local TutorialService = require(game.ReplicatedStorage.TutorialService)
_G.PlayerLearningData = {}
game.PhysicsService:CreateCollisionGroup("CoverPoints")
local CoverService = require(game.ServerStorage.CoverObjectService)(workspace.CoverSystem)
for i = 1, #workspace.CoverSystem.CoverSpawns:GetChildren() do
local CoverPoint = CoverService.CreateCover("CrateStackCover")
if CoverPoint:IsA("Model") then
for _, Child in pairs(CoverPoint.Sectors:GetChildren()) do
if Child:IsA("Model") then
for _, Child1 in pairs(Child:GetChildren()) do
if Child1:IsA("BasePart") then
game.PhysicsService:SetPartCollisionGroup(Child1,"CoverPoints")
end
end
end
end
end
end
workspace.CoverSystem.CoverObjects.ChildAdded:connect(function(CoverObj)
if CoverObj:IsA("Model") then
for _, Child1 in pairs(CoverObj.Sectors:GetChildren()) do
if Child1:IsA("Model") then
for _, Child2 in pairs(Child1:GetChildren()) do
if Child2:IsA("BasePart") then
game.PhysicsService:SetPartCollisionGroup(Child2,"CoverPoints")
end
end
end
end
end
end)
AnalyticsService.ServerInit("bc9b4f662366fe80ec026dfef12d2030","b4898f195d70a03b1c27abedc6056d9914c6ba1d")
do
local AmmoP = require(script.AmmoStorageProvider)
AmmoP:GetAllAmmoCrates(game.ReplicatedStorage.CoverPointStorage.CrateStackCover.PowerUps.Ammo)
AmmoP:AddToQueue(game.ReplicatedStorage.ITEMS)
AmmoP:AddToQueue(game.ReplicatedStorage.MobItems)
AmmoP:AddToQueue(game.StarterPack)
end
do
local RANDOM = math.random
local lighting = game:GetService("Lighting")
lighting.TimeOfDay = "6:00:00"
local ColorShift = require(game.ReplicatedStorage.ColorShift)
local ColorShifts = require(workspace.Settings.ColorShifts)
-- dayLength defines how long, in minutes, a day in your game is. Feel free to alter it.
local dayLength = 24
local cycleTime = dayLength*60
local minutesInADay = 24*60
local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime
local timeRatio = minutesInADay / cycleTime
if dayLength == 0 then
dayLength = 1
end
spawn(function()
local t = 0
repeat
local tW = wait(1)
local currentTime = tick()
currentTime = currentTime + (tW/(1))
if currentTime > endTime then
startTime = endTime
endTime = startTime + cycleTime
end
lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
lighting.SunRays.Intensity = 0.5/t
t = lighting:GetMinutesAfterMidnight() -360
if lighting.ClockTime >= (17+(4/6)) then
t = (lighting:GetMinutesAfterMidnight() -1080)*-1
end
if lighting.SunRays.Intensity >= 29.9 then
lighting.SunRays.Intensity = 30
elseif lighting.SunRays.Intensity <= 0.026 then
lighting.SunRays.Intensity = 0.025
end
local b = lighting:GetMinutesAfterMidnight()
lighting.ColorShift_Top = Color3.new(255/255, 255/255, 255/255)
lighting.OutdoorAmbient = Color3.new(32/255, 32/255, 32/255)
for _, cShift in pairs(ColorShifts) do
if cShift:IsInRange(b) then
cShift()
end
end
until false
end)
end
do
local DataManager = require(script.Parent.DataManager)
local Starting = require(game.Workspace.Settings.Starting)
local Caps = require(game.Workspace.Settings.Caps)
local Others = require(game.Workspace.Settings.Others)
local PVP = require(game.Workspace.Settings.PVP)
local PerLevel = require(game.Workspace.Settings.PerLevel)
local AttributeEffect = require(game.Workspace.Settings.AttributeEffect)
local QuestService = require(script.Parent.QuestService)
local ForceLib = require(game.ReplicatedStorage.ForceLib)
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local BindableService = require(game.ReplicatedStorage.BindingService)()
local TweenService = game:GetService("TweenService")
local KillService = require(game.ServerScriptService.KillService)
local ArmorService = require(game.ReplicatedStorage.ArmorModule)
local MarketLib = require(game.ReplicatedStorage.MarketService)
local old_fog = game.Lighting.FogStart
local MarketplaceService = game:GetService("MarketplaceService")
local ItemPersistence = require(game.Workspace.Settings.ItemPersistence)
local TSS = require(game.ServerScriptService.ToolStoreService)
local ComlinkSettings = require(game.Workspace.Settings.Comlink)
local TextService = game.TextService
local gbl = require(game.ReplicatedStorage.Global)
local webhook = "https://discordapp.com/api/webhooks/280936751281864704/mBB62mVJffxdL_M82LB9EkNg74g8-eipjESIQLTlzzn4b1P2x-Il8OR8lrvne6gHnbKW"
local HTTP = game:GetService("HttpService")
local CHAT = game:GetService("Chat")
local SpawnDelayTime = 999999999999
local titles = require(script.Titles)
local fn = require(script.Functions)
local folder = script.Resources.iTitle
local data
local ServerJobs = require(game.Workspace.Settings.ServerJobs)
local ServerJob = require(game.ReplicatedStorage.ServerJob)
local Traits = require(workspace.Settings.Traits)
local Trait = require(game.ReplicatedStorage.Trait)
local PlayerTraits = {}
local Healthbar = require(game.ReplicatedStorage.Healthbar)
local MagInfo = require(game.ReplicatedStorage.MagInfo)
local HBs = {}
local AutosaveRoutines = {}
for _, Shop in pairs(workspace.Map.Venues.BlasterShops:GetChildren()) do
if Shop then
Shop.EntryZone.Touched:connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
if plr then
RemoteService.send("Client",plr,"SetNPCToTalk",Shop.Keeper.Value)
end
end
end)
end
end
local RPGM = require(game.ReplicatedStorage.RPGMathProvider)
game.StarterPlayer.NameDisplayDistance = 0
fn:init(titles)
QuestService.Handlers["ObjectiveComplete"] = function(plr,objective,quest)
AnalyticsService.RecordQuestProgress(plr,"Complete",objective.XPGain,quest.Name,"Objective",objective.Name)
end
QuestService.Handlers["StartQuest"] = function(plr,quest)
AnalyticsService.RecordQuestProgress(plr,"Start",0,quest.Name,"Quest")
end
local InventoryService = require(game.ReplicatedStorage.InventoryService)
InventoryService.startServer()
local PlayerLoadouts = {}
local LoadoutWeapons = {}
local AchievementCache = {}
local PowersCache = {}
local Players = {}
local ChatTags = {}
local AutosaveStates = {}
local CurrentJob = {}
local PlayerQuests = {}
local Squads = {}
local AchievementObj = require(game.ReplicatedStorage.Achievement)
local AchievementList = require(game.Workspace.Settings.Achievements)
local OnDeath_Callback = function(player)
print(player.Name .. " died. Awaiting respawn.")
end
local AllTags = require(game.Workspace.Settings.AllTags)
local forceSaveCommand = ItemPersistence.forceSaveCommand
local forceLoadCommand = ItemPersistence.forceLoadCommand
local clearStarterGearOnLoad = ItemPersistence.clearStarterGearOnLoad
local forceClearCommand = ItemPersistence.forceClearCommand
local saveCooldownTime = ItemPersistence.saveCooldownTime
local loadCooldownTime = ItemPersistence.loadCooldownTime
local DEBUG = ItemPersistence.DEBUG
-- Changing the strings is perfectly acceptable!
local strings = {
saveSuccessMsg = ItemPersistence.saveSuccessMsg,
loadSuccessMsg = ItemPersistence.loadSuccessMsg,
saveErrorMsg = ItemPersistence.saveErrorMsg,
loadErrorMsg = ItemPersistence.loadErrorMsg,
loadFastMsg = ItemPersistence.loadFastMsg
}
local save_times = {}
local load_times = {}
local toolDuplicates = {}
local debris = game:GetService("Debris")
local function getPlayerFromId(id)
for i,v in pairs(game.Players:GetChildren()) do
if v.userId == id then
return v
end
end
return nil
end
local CheatService = require(game.ReplicatedStorage.CheatService)
local Cheats = require(game.Workspace.Settings.Cheats)
local ARRHardwareMethods = {
["ToggleHelmet"] = function(player,a1,a2,a3)
if player.Character.Hardware.Case.Transparency == 0 then
for _,g in pairs(player.Character.Hardware:GetChildren()) do
g.Transparency = 1
wait()
end
for _,h in pairs(player.Character:GetChildren()) do
if h:IsA("Hat") then
for _,p in pairs(h:GetChildren()) do
if p:IsA("Part") or p:IsA("UnionOperation") then
p.Transparency = 0
end
end
end
wait()
end
elseif player.Character.Hardware.Case.Transparency == 1 then
for _,g in pairs(player.Character.Hardware:GetChildren()) do
g.Transparency = 0
wait()
end
for _,h in pairs(player.Character:GetChildren()) do
if h:IsA("Hat") then
for _,p in pairs(h:GetChildren()) do
if p:IsA("Part") or p:IsA("UnionOperation") then
p.Transparency = 1
end
end
end
wait()
end
end
end;
["TacticalCombat"] = function(player,a1,a2,a3)
player.Character:FindFirstChild("Hardware").Glass.BrickColor = a2
end;
["Jetpack"] = function(player,a1,a2,a3)
player.Character.Humanoid.JumpPower = a2
end;
["Shield"] = function(player,a1,a2,a3)
player.Character.Humanoid.MaxHealth = (a2 and a3.Max or a3.Min)
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
end;
["Thrust"] = function(player,a1,a2,a3)
if a2 == "Left" then
local vel = Instance.new ("BodyVelocity",player.Character.Torso)
vel.MaxForce = Vector3.new (40000000, 40000000, 40000000)
local lvec = player.Character.Head.CFrame.lookVector
vel.Velocity = Vector3.new (lvec.X*-50,25,lvec.Z*-50)
game:GetService("Debris"):AddItem(vel,0.5)
elseif a2 == "Right" then
local vel = Instance.new ("BodyVelocity",player.Character.Torso)
vel.MaxForce = Vector3.new (40000000, 40000000, 40000000)
local lvec = player.Character.Head.CFrame.lookVector
vel.Velocity = Vector3.new (lvec.X*50,25,lvec.Z*50)
game:GetService("Debris"):AddItem(vel,0.5)
end
end;
}
RemoteService.listen("Server","Fetch","RedeemCode",function(player,code)
local CheatSave = CheatService:LoadCheatSave(player)
if Cheats[code] ~= nil then
if CheatService:GetSavedCheat(player,code) then
return "Code already redeemed."
else
local success, codeRedeemed = CheatService:RunCheat(Cheats[code],player)
if codeRedeemed then
CheatService:MarkCheatAsRedeemed(Cheats,CheatSave,code)
CheatService:SaveCheats(player,CheatSave)
return "Redeemed \"".. Cheats[code].Name .. "\" successfully!"
else
return "Error occured"
end
end
else
return "Invalid Cheat."
end
end)
RemoteService.listen("Server","Send","ChangeAttribute",function(player,attrName,value)
if player.attributes.APs.Value > 0 then
player.attributes:FindFirstChild(attrName).Value = value
if attrName == "Constitution" then
player.Character.Humanoid.MaxHealth = RPGM.MaxHP(player.leaderstats.Lvl,player.attributes.Constitution)
elseif attrName == "Intellgence" then
player.Stats.MaxMana.Value = RPGM.Mana(player.leaderstats.Lvl,player.attributes.Intelligence)
end
end
end)
RemoteService.listen("Server","Send","ARRCommandoConduit",function(player,a1,a2,a3)
if ARRHardwareMethods[a1] then
ARRHardwareMethods[a1](player,a1,a2,a3)
end
end)
RemoteService.listen("Server","Send","ResetAttributesCredits",function(player)
if player.leaderstats.Credits.Value >= (Others.AttributeResetCostInitial + (Others.AttributeResetCostPerLevel * player.leaderstats.Lvl.Value)) then
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value - (Others.AttributeResetCostInitial + (Others.AttributeResetCostPerLevel * player.leaderstats.Lvl.Value))
player.attributes.Strength.Value = Starting.StartingAttributes
player.attributes.Constitution.Value = Starting.StartingAttributes
player.attributes.Intelligence.Value = Starting.StartingAttributes
player.attributes.Dexterity.Value = Starting.StartingAttributes
RemoteService.send("Client",player,"ResetAttributes")
end
end)
RemoteService.listen("Server","Fetch","HasGamepass",function(player,passId)
return game.GamePassService:PlayerHasPass(player,passId)
end)
RemoteService.listen("Server","Fetch","EquipEquipment",function(player,armorName,armorData)
ArmorService:EquipArmorByName(player.Character, armorName)
return true
end)
RemoteService.listen("Server","Fetch","RemoveEquipment",function(player)
DataManager:GetArmorWithPlacement(player,DataManager:GetCurrentPlacement(player)).Armor:Remove()
return true
end)
BindableService.listen("Server","Fetch","GetCurrentArmor",function(player)
return DataManager:GetArmorWithPlacement(player,DataManager:GetCurrentPlacement(player)).Armor
end)
BindableService.listen("Fetch","IsEquipmentReady",function(player)
return DataManager:IsEquipmentReady(player)
end)
RemoteService.listen("Server","Fetch","MakeTransaction",function(player,transType,amount)
if transType == "Withdraw" then
return MarketLib:Withdraw(player.UserId,amount,false)
elseif transType == "Deposit" then
return MarketLib:Deposit(player.UserId,amount,false)
end
end)
RemoteService.listen("Server","Fetch","IsArmorEquipped",function(player,armor)
local armorObj = DataManager:GetArmorWithPlacement(player,DataManager:GetCurrentPlacement(player)).Armor
return armor == armorObj.Name and armorObj:IsEquipped()
end)
MarketLib:BindToProcessReceipt("Main",function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local ProductPrice = receiptInfo.CurrencySpent
local player = getPlayerFromId(playerId)
if MarketLib:IsA(productId,"Product") then
local player2,result = MarketLib:GetPurchaseResult(productId,"Products",player,ProductPrice)
if typeof(result) == "string" then
MarketLib:ProcessCharacterProduct(player,result:sub(1,1),result:sub(3))
elseif typeof(result) == "Instance" then
if result:IsA("Tool") then
print(result.Name)
MarketLib:GrantItem(result,player2)
elseif result:IsA("ScreenGui") then
MarketLib:GrantGui(result,player2)
end
end
elseif MarketLib:IsA(productId,"Service") then
MarketLib:GetPurchaseResult(productId,"Services",player,ProductPrice)(player,ProductPrice)
elseif MarketLib:IsA(productId,"PowerUp") then
--local result = MarketLib:GetPurchaseResult(productId,"Services",player,ProductPrice)(player,ProductPrice)
end
MarketLib:MarkPurchaseAsRead(receiptInfo)
return Enum.ProductPurchaseDecision.PurchaseGranted
end, {
33588023;
33550001;
33597658;
33549679;
33549702;
33554346;
33549876;
35197593;
30925114;
33549876;
30925114;
33549611;
35197630;
33554409;
33837609;
34178808;
31246289;
42843654;
33549581;
31433922;
33220315;
})
MarketLib:BindToProcessReceipt("PlayerState",function(receiptInfo)
local player = getPlayerFromId(receiptInfo.PlayerId)
local productId = receiptInfo.ProductId
if productId == 123787478 then
local newName = RemoteService.fetch("Client",player,"GetNewName")
if newName == player.CharacterName.Value then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
player.CharacterName.Value = newName
return Enum.ProductPurchaseDecision.PurchaseGranted
end
elseif productId == 123759458 then
local result = RemoteService.fetch("Client",player,"PromptRebirth")
if result then
RemoteService.send("Client",player,"RebirthClient")
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end,{
123787478;
123759458;
})
MarketLib:OpenCheckout()
function filterMessage(player,message)
local textResult = TextService:FilterStringAsync(message,player.UserId)
return textResult:GetNonChatStringForBroadcastAsync()
end
RemoteService.listen("Server","Fetch","FilterStringBroadcast",function(player,message)
return filterMessage(player,message)
end)
RemoteService.listen("Server","Fetch","GetGUID",function(player)
return HTTP:GenerateGUID(false)
end)
BindableService.listen("Send","CreateLoadout",function(player,loadoutData)
PlayerLoadouts[player.UserId] = InventoryService.LoadoutClass.new(loadoutData.Name,loadoutData.Primary,loadoutData.Secondary,loadoutData.Explosive,loadoutData.Gadget,loadoutData.Melee)
end)
local function createServerJob(name)
local SJ = ServerJob.new(name)
for _, step in pairs(ServerJobs[name].Steps) do
if step then
SJ:AddStep(step)
end
end
return SJ
end
RemoteService.listen("Server","Send","RunServerJob",function(player,jobName)
CurrentJob[player.UserId] = createServerJob(jobName)
CurrentJob[player.UserId](true,player)
end)
RemoteService.listen("Server","Send","Unlock",function(player,forcePower)
if not PowersCache[player.UserId][forcePower].HasPower then
ForceLib:UpdatePower(player,PowersCache,forcePower,"HasPower",true)
RemoteService.send("Client",player,"NotifyForcePowerUnlocked",PowersCache[player.UserId][forcePower].FriendlyName,25)
player.leaderstats.XP.Value = player.leaderstats.XP.Value + 25
else
ForceLib:UpdatePower(player,PowersCache,forcePower,"Level",PowersCache[player.UserId][forcePower].Level + 1)
RemoteService.send("Client",player,"NotifyForcePowerUnlocked",PowersCache[player.UserId][forcePower].FriendlyName .. " - LV ".. PowersCache[player.UserId][forcePower].Level,25)
player.leaderstats.XP.Value = player.leaderstats.XP.Value + 25
end
end)
RemoteService.listen("Server","Fetch","GetForcePowerLevel",function(player,powerName)
return PowersCache[player.UserId][powerName].Level
end)
RemoteService.listen("Server","Fetch","GetForcePowerManaCost",function(player,powerName)
return PowersCache[player.UserId][powerName].ManaCost
end)
RemoteService.listen("Server","Fetch","IsForcePowerActive",function(player,powerName)
return PowersCache[player.UserId][powerName].Active
end)
RemoteService.listen("Server","Fetch","HasForcePower",function(player,powerName)
return PowersCache[player.UserId][powerName].HasPower
end)
RemoteService.listen("Server","Send","ForcePowerUpgradeCompleted",function(player)
if player.Character then
if player.Character:FindFirstChildOfClass("ForceField") then
player.Character:FindFirstChildOfClass("ForceField"):Destroy()
end
end
end)
RemoteService.listen("Server","Send","StartCustomization",function(player)
local Char = game.ReplicatedStorage.StarterCharacter
RemoteService.send("Client",player,"ViewCharacterStage",player.CustomizationSlot.Value.ViewPart)
end)
game.ReplicatedStorage.StartNewSquadMember.OnServerEvent:connect(function(player)
local Char = (player.Allegiance.Value == "Good" and game.ReplicatedStorage.StarterRebel:Clone() or game.ReplicatedStorage.StarterTrooper:Clone())
Char.Parent = game.Workspace.SquadCustomizationUnits
Char.PrimaryPart.CFrame = (Char:GetPrimaryPartCFrame()*CFrame.Angles(0, math.rad(180), 0))
game.ReplicatedStorage.StartNewSquadMember:FireClient(player,Char)
end)
game.ReplicatedStorage.DestroySoldierModel.OnServerEvent:connect(function(player,squadMember)
local member
for _, mate in pairs(workspace.SquadCustomizationUnits:GetChildren()) do
if squadMember == mate then
member = mate
break
end
end
if member then
member:Destroy()
end
end)
game.ReplicatedStorage.RigSquadMember.OnServerEvent:connect(function(player,squadMember,cf)
squadMember:SetPrimaryPartCFrame(cf)
end)
BindableService.listen("Send","ApplyLoadout",function(player)
PlayerLoadouts[player.UserId]:SendToStarterGear(player)
end)
RemoteService.listen("Server","Fetch","Trading",function(p,arg,target,tool)
if arg == 'GetSettings' then
return {
Group = 1155669,
Rank = 1,
}
elseif arg == 'HandTo' then
if target and tool then
RemoteService.fetch("Client",target,"Trading",'HandTo',p,tool)
end
elseif arg == 'Yes' then
if target and tool then
local newtool = tool:clone()
tool:Destroy()
newtool.Parent = p.Backpack
RemoteService.send("Client",p,"ShowDialog","Item",tostring(target.Name).." has given you his or her "..newtool.Name..".",8)
end
end
end)
RemoteService.listen("Server","Send","SpawnLoot",function(plr)
local SupplyCrate = game.ServerStorage.Supplies:Clone()
SupplyCrate:SetPrimaryPartCFrame(CFrame.new(plr.Character.Torso.Position) + Vector3.new(10,90,0))
SupplyCrate.Parent = game.Workspace
end)
function tellPlayer(player, text)
if not player.Parent then return end
RemoteService.send("Client",player,"ShowDialog",player.Name,text,8)
end
local function playerSave(player)
if (save_times[player] or 0) + 30 > tick() then
tellPlayer(player, strings.saveFastMsg)
return
end
save_times[player] = tick()
local gear = player:FindFirstChild("Inventory")
local tools = gear:GetChildren()
local TSPlayer = TSS:GetToolArray(player)
local TSArray = TSPlayer
print(TSArray)
if TSArray == nil then
TSArray = {}
TSPlayer= TSArray
TSS:SaveTools(player)
else
TSS:SaveTools(player)
end
tellPlayer(player, strings.saveSuccessMsg)
end
RemoteService.listen("Server","Send","SaleAdded",function(player,v)
RemoteService.bounce("Client","ProcessPawn",v)
end)
RemoteService.listen("Server","Fetch","BuyUsedItem",function(player,item)
local seller = item:WaitForChild("SaleStats",400).Seller.Value
if player == seller then
return {
ResultType = "Error",
Result = "You cannot buy this item; you are the vendor for it!"
}
end
if item then
if player.leaderstats.Credits.Value > item.SaleStats.PriceDisplay.Value then
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value - item.SaleStats.PriceDisplay.Value
seller.leaderstats.Credits.Value = seller.leaderstats.Credits.Value + item.SaleStats.PriceDisplay.Value
RemoteService.bounce("Client","RemoveOffer",item.SaleStats)
RemoteService.send("Client",seller,"ShowDialog","Item",player.Name .. " has accepted one of your offers!",4)
item.SaleStats:Destroy()
item.Parent = player.Backpack
item:Clone().Parent = player.Inventory
return {
ResultType = "Success";
Result = item;
}
else
return {
ResultType = "Error",
Result = "Insufficient funds prevent this transaction!";
}
end
end
end)
RemoteService.listen("Server","Fetch","GetOfferItem",function(player,item,price,displayName,desc,img)
local ToolCopy = gbl:FindFirstItemWithId(player.Backpack,item.ID.Value)
if item then
item.Parent = game.ReplicatedStorage:WaitForChild("PawnStorage",400)
ToolCopy:Destroy()
local SaleStats = Instance.new("IntValue")
SaleStats.Name = "SaleStats"
SaleStats.Parent = item
local iName = Instance.new("StringValue")
iName.Name = "ItemName"
iName.Value = displayName
iName.Parent = SaleStats
local iDesc = Instance.new("StringValue")
iDesc.Name = "ItemDescription"
iDesc.Value = desc
iDesc.Parent = SaleStats
local iPrice = Instance.new("IntValue")
iPrice.Name = "PriceDisplay"
iPrice.Value = tonumber(price)
iPrice.Parent = SaleStats
local iImage = Instance.new("StringValue",SaleStats)
iImage.Name = "ItemImage"
iImage.Value = img
iImage.Parent = SaleStats
local Seller = Instance.new("ObjectValue")
Seller.Name = "Seller"
Seller.Value = player
Seller.Parent = SaleStats
local iID = Instance.new("IntValue")
iID.Name = "ItemId"
iID.Value = item.ID.Value
iID.Parent = SaleStats
return item, SaleStats
end
return nil
end)
function playerLoad(player)
local gear = player:FindFirstChild("Inventory")
local TSArray = TSS:GetToolArray(player)
if TSArray == nil then
TSArray = {}
TSS:SaveTools(player,TSArray)
else
TSS:LoadTools(player,TSArray)
end
if (load_times[player] or 0) + 60*loadCooldownTime > tick() then
tellPlayer(player, strings.loadFastMsg)
return
end
load_times[player] = tick()
end
BindableService.listen("Send","LoadInventory",function(player)
playerLoad(player)
end)
RemoteService.listenLocal("Server","Send","SaveItems",function(player)
playerSave(player)
end)
RemoteService.listenLocal("Server","Send","ClearCommand",function(player)
TSS:ClearTools(player)
end)
RemoteService.listenLocal("Server","Send","LoadItems",function(player)
local success, error = pcall(function() playerLoad(player) end)
if not success then
if DEBUG then tellPlayer(player, "playerLoad error:" .. error) end
else
playerLoad(player)
end
end)
--local PlayerStates = require(script.Parent.PlayerState)
function removePlayer(player)
for i, plr in pairs(Players) do
if plr == player then
Players[i] = nil
break
end
end
end
BindableService.listen("Fetch","GetCompletedAchievements",function(player)
local result = {}
for _, achievement in pairs(AchievementCache[player.UserId]) do
if achievement.Completed then
result[#result+1] = tostring(achievement)
end
end
return result
end)
BindableService.listen("Fetch","GetAcquiredTraits",function(player)
local result = {}
for _, trait in pairs(PlayerTraits[player.UserId]) do
if Trait.HasTrait(player,trait) then
result[#result+1] = tostring(trait)
end
end
return result
end)
BindableService.listen("Send","ResetForcePowers",function(player)
DataManager:ResetForcePowers(player)
end)
BindableService.listen("Send","DisableAutosave",function(player)
AutosaveStates[player.UserId] = false
end)
function onPlayerEntered(player)
Players[#Players+1] = player
AchievementCache[player.UserId] = {}
PlayerQuests[player.UserId] = {}
PlayerTraits[player.UserId] = {}
CurrentJob[player.UserId] = "None"
AutosaveStates[player.UserId] = false
for _, trait in pairs(Traits) do
PlayerTraits[player.UserId][trait.Name] = trait
PlayerTraits[player.UserId][trait.Name]:SetPlayer(player)
end
for _, trait in pairs(PlayerTraits[player.UserId] ) do
for _, traitName in pairs(DataManager:GetSavedTraits(player)) do
if trait.Name == traitName then
trait.On = true
end
end
end
for _, ach in pairs(AchievementList) do
AchievementCache[player.UserId][#AchievementCache[player.UserId] + 1] = ach
AchievementCache[player.UserId][#AchievementCache[player.UserId]]:SetPlr(player)
end
for _, ach in pairs(AchievementCache[player.UserId]) do
for _, achName in pairs(DataManager:GetSavedAchievements(player)) do
if ach.Name == achName then
ach.Completed = true
end
end
end
AnalyticsService:ServerEvent({
["category"] = "user";
["event_id"] = "Saberfront:PlayerJoined:" .. player.Name
},player)
local Data = TutorialService.GetSavedLearningProfile(player)
_G.PlayerLearningData[player.UserId] = Data
game.CollectionService:AddTag(player,player.Name)
local i8Folder = Instance.new("Folder")
i8Folder.Name = "Inventory"
i8Folder.Parent = player
local DeploymentMode = Instance.new("StringValue")
DeploymentMode.Name = "DeploymentMode"
DeploymentMode.Value = DataManager:LoadDeploymentMode(player) or "Transport"
DeploymentMode.Parent = player
local I8Mode = Instance.new("StringValue")
I8Mode.Name = "i8Mode"
I8Mode.Value = DataManager:GetSavedInventoryMode(player) or "Basic"
I8Mode.Parent = player
playerLoad(player)
spawn(function()
DataManager:loadScores(player,Starting,Others,AttributeEffect,PerLevel,Caps,PVP,PowersCache)
end)
local PlrData = DataManager.PData:GetAsync(player.Name .. "-id")
if PlrData and PlrData.AlreadyCustomized then
if PlrData.Loadout ~= {} and PlrData.Loadout["Primary"] and PlrData.Loadout["Melee"] then
PlayerLoadouts[player.UserId] = InventoryService.LoadoutClass.Deserialize(player,DataManager:GetSavedLoadout(player))
PlayerLoadouts[player.UserId]:SendToStarterGear(player)
else
PlayerLoadouts[player.UserId] = InventoryService.LoadoutClass.Deserialize(player,DataManager:GetClassLoadout(PlrData.Team))
PlayerLoadouts[player.UserId]:SendToStarterGear(player)
end
else
PlayerLoadouts[player.UserId] = InventoryService.LoadoutClass.new("Main",nil,nil,nil,nil,nil)
end
LoadoutWeapons[player.UserId] = {}
if CheatService:LoadCheatSave(player) == nil then
CheatService:SaveCheats(player,{})
end
local Data = DataManager:GetSavedData(player,Starting)
local Kills = Data.KDR.Kills
KillService:RegisterPlayer(player,Kills)
player:WaitForChild("leaderstats",200).Lvl.Changed:connect(function(value)
if value > 1 then
if BindableService.fetch("HasTrait",player,"ForceSensitivity") then
if player.Character then
local forceField = Instance.new("ForceField")
forceField.Parent = player.Character
end
RemoteService.send("Client",player,"EnableForceUnlock")
end
local CreditsToGive = RPGM:GetCreditsPerLevel(value,player.attributes.Charisma.Value)
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + CreditsToGive
RemoteService.send("Client",player,"LevelUp",value,CreditsToGive,{})
wait(4)
RemoteService.bounce("Client","ShowDialog",player.Name,player.Name .. " has gained a level!",10)
end
end)
ChatTags[player.UserId] = {}
for name, tag in pairs(AllTags) do
if tag.Player(player) then
ChatTags[player.UserId][name] = tag
end
end
player.Changed:connect(function()
ChatTags[player.UserId] = {}
for name, tag in pairs(AllTags) do
if tag.Player(player) then
ChatTags[player.UserId][name] = tag
end
end
end)
for _, v in pairs(player.attributes:GetChildren()) do
if v.Name ~= "APs" then
v.Changed:connect(function(attrValue)
player.attributes.APs.Value = player.attributes.APs.Value - (attrValue < Caps.AttributeCap and 1 or 0)
end)
end
end
local Data
repeat wait(0.2) until RemoteService.fetch("Client",player,"PlayerReady") == true
print("Loading Character...")
player:LoadCharacter(true)
AutosaveRoutines[player.UserId] = coroutine.create(function()
while AutosaveStates[player.UserId] do
print("Attempting to save data for " .. player.Name)
local pointsPvP = player:FindFirstChild("leaderstats"):FindFirstChild("PVPRank")
if AutosaveStates[player.UserId] then
local AutoSaveSuccessful = DataManager:saveScores(player, pointsPvP)
if AutoSaveSuccessful then
playerSave(player)
RemoteService.send("Client",player,"SendNotif","AutosaveSuccess")
else
RemoteService.send("Client",player,"SendNotif","AutosaveFailure")
end
end
wait(30)
end
end)
AutosaveStates[player.UserId] = true
coroutine.resume(AutosaveRoutines[player.UserId])
player.Character.Humanoid.Died:connect(function()
if (type(OnDeath_Callback) == "function") then OnDeath_Callback(player) end
end)
local newFolder = folder:Clone()
newFolder.Parent = player
repeat wait() until player.leaderstats:FindFirstChild('Lvl')
repeat wait() until player:FindFirstChild('CharacterName')
spawn(function()
while wait(15) do
DataManager:SetLoadoutForSaving(player,PlayerLoadouts[player.UserId]:Serialize())
end
end)
--repeat wait(0.2) until player.PlayerGui
--player.PlayerGui:WaitForChild("DialogGui",1200)
--playerLoad(player)
HBs[player.UserId] = Healthbar.new(player,titles[player.Team.Name][player.iTitle.Title.Value])
HBs[player.UserId]:Setup()
HBs[player.UserId]:UpdateName(player.CharacterName.Value)
player.CharacterAdded:connect(function(c)
local t = time()
while ((not c:FindFirstChild("Humanoid")) and ((time()-t) < 10)) do wait(0.2) end
if ((time()-t) >= 10) then print("Timeout error")
else
HBs[player.UserId] = Healthbar.new(player,titles[player.Team.Name][player.iTitle.Title.Value])
HBs[player.UserId]:Setup()
HBs[player.UserId]:UpdateName(player.CharacterName.Value)
end
c.Humanoid.Died:connect(function()
if (type(OnDeath_Callback) == "function") then OnDeath_Callback(player) end
end)
end)
-- try loading the player's score
RemoteService.send("Client",player,"UpdateCurrency",player.leaderstats.Credits.Value)
player.leaderstats.Credits.Changed:connect(function(value)
if value < 0 then
player.leaderstats.Credits.Value = 100
RemoteService.send("Client",player,"UpdateCurrency",player.leaderstats.Credits.Value)
else
RemoteService.send("Client",player,"UpdateCurrency",value)
end
end)
print("Ready to accomodate "..player.Name)
end
RemoteService.listen("Server","Send","ChangeName",function(player,text)
player.CharacterName.Value = filterMessage(player,text)
end)
RemoteService.listen("Server","Send","GiveWeapons",function(player,...)
local args = {...}
player.Inventory:ClearAllChildren()
for _, item in pairs(require(game.Teams:FindFirstChild(args[1]).WeaponsList)(player)) do
item.Parent = player.Inventory
end
end)
game.Teams.Jedi.PlayerAdded:connect(function(player)
player:WaitForChild("AlreadyCustomized",200)
if not player.AlreadyCustomized.Value then
PlayerTraits[player.UserId]["Mandalorian"]:Retract()
PlayerTraits[player.UserId]["Imperial"]:Retract()
PlayerTraits[player.UserId]["ForceSensitivity"]:Give()
end
end)
game.Teams["Bounty Hunters"].PlayerAdded:connect(function(player)
player:WaitForChild("AlreadyCustomized",200)
if not player.AlreadyCustomized.Value then
PlayerTraits[player.UserId]["Commando"]:Retract()
PlayerTraits[player.UserId]["Rebel"]:Retract()
if math.random(1,2) == 1 then
PlayerTraits[player.UserId]["ForceSensitivity"]:Retract()
end
--TODO: IMPLEMENT SOMETHING TO CHECK IF BOUNTY HUNTERS ARE HUMAN OR NON-HUMAN\
end
end)
game.Teams.Imperials.PlayerAdded:connect(function(player)
player:WaitForChild("AlreadyCustomized",200)
if not player.AlreadyCustomized.Value then
PlayerTraits[player.UserId]["Mandalorian"]:Retract()
PlayerTraits[player.UserId]["Rebel"]:Retract()
if math.random(1,2) == 1 then
PlayerTraits[player.UserId]["ForceSensitivity"]:Retract()
end
PlayerTraits[player.UserId]["Imperial"]:Give()
end
end)
game.Teams.Rebels.PlayerAdded:connect(function(player)
player:WaitForChild("AlreadyCustomized",200)
if not player.AlreadyCustomized.Value then
PlayerTraits[player.UserId]["Mandalorian"]:Retract()
PlayerTraits[player.UserId]["Imperial"]:Retract()
if math.random(1,2) == 1 then
PlayerTraits[player.UserId]["ForceSensitivity"]:Retract()
end
PlayerTraits[player.UserId]["Rebel"]:Give()
end
end)
RemoteService.listen("Server","Send","ChangeClass",function(player,team)
player.Team = team
player.Allegiance.Value = ((player.Team.Name == "Bounty Hunters" or player.Team.Name == "Imperials") and "Evil" or "Good")
end)
RemoteService.listen("Server","Fetch","MakePurchase",function(player,item,shopType)
local Cash = player.leaderstats:FindFirstChild("Credits")
local cost = item.Cost
local Balance, hasEnoughMoney = MarketLib:Withdraw(player.UserId,cost,true,shopType,item.Name)
if hasEnoughMoney then
local itemA = gbl:GetItem(item.LiteralName):Clone()
local itemB = itemA:Clone()
itemB.Parent = player.Backpack
itemA.Parent = player.Inventory
RemoteService.send("Client",player,"ShowDialog","Item","You have bought "..item.ItemName.. "!",5)
return "Success"
else
RemoteService.send("Client",player,"ShowDialog","Item","You don't have enough Credits for " .. item.ItemName .. ". Sorry!",5)
return "Failure"
end
end)
RemoteService.listen("Server","Send","ChangeProp",function(player,prop,value)
-- local Props = {
-- ["Name"] = player.CharacterName;
-- ["Level"] = player.leaderstats.Lvl;
-- ["XP"] = player.leaderstats.XP;
-- ["GamepadMode"] = player.UIStats.GamepadMode;
-- ["SkinColor"] = player.CharacterAppearanceData.SkinColor;
-- ["HairColor"] = player.CharacterAppearanceData.HairColor;
-- ["PantsTemplate"] = player.CharacterAppearanceData.PantsTemplate;
-- ["ShirtTemplate"] = player.CharacterAppearanceData.ShirtTemplate;
--
-- }
-- Props[propKey].Value = value
prop.Value = value
end)
game.Players.PlayerAdded:connect(onPlayerEntered)
for _, plr in pairs(game.Players:GetPlayers()) do
onPlayerEntered(plr)
end
RemoteService.listen("Server","Fetch","GetStarterItems",function(player)
return player.Inventory:GetChildren()
end)
RemoteService.listen("Server","Send","DestroyMag",function(player,model)
if model:IsDescendantOf(workspace.Loot.Ammo) then
model:Destroy()
end
end)
RemoteService.listen("Server","Fetch","AutosaveEnabled",function(player)
return AutosaveStates[player.UserId]
end)
RemoteService.listen("Server","Fetch","MicFetch",function(player,channel,text)
if channel == 'Team' then
for i,p in pairs (game.Players:GetPlayers()) do
if p.TeamColor == player.TeamColor then
RemoteService.send("Client",p,"MicSend",tostring(player),channel,text)
end
end
elseif channel == 'Global' then
for i,p in pairs (game.Players:GetPlayers()) do
if player.Character and p:DistanceFromCharacter(player.Character.Torso.Position) <= Settings.Range then
RemoteService.send("Client",p,"MicSend",tostring(player),channel,text)
end
end
elseif channel == 'Settings' then
return ComlinkSettings
end
end)
RemoteService.listen("Server","Send","PlayerDiedServer",function(player,respawnInGame)
print("Respawning " .. player.Name .. "...")
player:LoadCharacter(respawnInGame)
end)
local GunEnv = require(game.ReplicatedStorage.GunLibraries.BlasterEnv)
local gunEnv
if _G.ignoreCode then
gunEnv = GunEnv.GetFromCode(_G.ignoreCode)
else
_G.ignoreCode = math.random(1, 1e4)
gunEnv = GunEnv.new("Main",_G.ignoreCode)
end
RemoteService.listen("Server","Send","AddGunClient",function(player,client)
gunEnv:RegisterClient(client,_G.ignoreCode)
end)
RemoteService.listen("Server","Fetch","GetGunEnv",function(player)
return {
IgnoreModel = gunEnv.IgnoreModel;
Code = gunEnv.Code;
GrenadeContainer = gunEnv.GrenadeContainer;
}
end)
RemoteService.listen("Server","Fetch","SendFeedback",function(player, msg)
local payload = HTTP:JSONEncode({
content = filterMessage(player,msg),
username = player.Name.." - (#"..player.UserId..")"
})
HTTP:PostAsync(webhook, payload)
return "Feedback recieved!"
end)
BindableService.listen("Send","SaveInventory",function(player)
playerSave(player)
end)
function onPlayerLeft(player)
PlayerQuests[player.UserId] = nil
coroutine.yield(AutosaveRoutines[player.UserId])
TutorialService.SaveData(player,_G.PlayerLearningData[player.UserId])
gunEnv:RemoveUser(player.Name)
removePlayer(player)
end
game.Players.PlayerRemoving:connect(onPlayerLeft)
RemoteService.listen("Server","Send","SetI8Mode",function(player,mode)
player.i8Mode.Value = mode
end)
RemoteService.listen("Server","Send","NPCSay",function(player,obj,msg,color)
game.Chat:Chat(obj.Head,msg,color)
end)
--RemoteService.listen("Server","Send","ARRCommandoConduit",function(player,a1,a2,a3)
-- if a1 == "ToggleHelmet" then
-- if player.Character.Hardware.Case.Transparency == 0 then
-- for _,g in pairs(player.Character.Hardware:GetChildren()) do
-- g.Transparency = 1
-- wait()
-- end
-- for _,h in pairs(player.Character:GetChildren()) do
-- if h:IsA("Hat") then
-- for _,p in pairs(h:GetChildren()) do
-- if p:IsA("Part") or p:IsA("UnionOperation") then
-- p.Transparency = 0
-- end
-- end
-- end
-- wait()
-- end
-- elseif player.Character.Hardware.Case.Transparency == 1 then
-- for _,g in pairs(player.Character.Hardware:GetChildren()) do
-- g.Transparency = 0
-- wait()
-- end
-- for _,h in pairs(player.Character:GetChildren()) do
-- if h:IsA("Hat") then
-- for _,p in pairs(h:GetChildren()) do
-- if p:IsA("Part") or p:IsA("UnionOperation") then
-- p.Transparency = 1
-- end
-- end
-- end
-- wait()
-- end
-- end
-- elseif a1 == "TacticalCombat" then
-- player.Character:FindFirstChild("Hardware").Glass.BrickColor = a2
-- elseif a1 == "Jetpack" then
-- player.Character.Humanoid.JumpPower = a2
-- elseif a1 == "Thrust" then
-- if a2 == "Left" then
-- local vel = Instance.new ("BodyVelocity",player.Character.Torso)
-- vel.MaxForce = Vector3.new (40000000, 40000000, 40000000)
-- local lvec = player.Character.Head.CFrame.lookVector
-- vel.Velocity = Vector3.new (lvec.X*-50,25,lvec.Z*-50)
-- game:GetService("Debris"):AddItem(vel,0.5)
-- elseif a2 == "Right" then
-- local vel = Instance.new ("BodyVelocity",player.Character.Torso)
-- vel.MaxForce = Vector3.new (40000000, 40000000, 40000000)
-- local lvec = player.Character.Head.CFrame.lookVector
-- vel.Velocity = Vector3.new (lvec.X*50,25,lvec.Z*50)
-- game:GetService("Debris"):AddItem(vel,0.5)
-- end
-- elseif a1 == "Health" then
-- player.Character.Humanoid:TakeDamage(a2)
-- end
--end)
RemoteService.listen("Server","Send","ChangeAppearance",function(player,CharData)
for Key, Value in pairs(CharData) do
player.CharacterAppearanceData:FindFirstChild(Key).Value = Value
end
end)
RemoteService.listen("Server","Fetch","AlreadyCustomized",function(player)
return player.AlreadyCustomized.Value
end)
RemoteService.listen("Server","Bounce","PlayCharacterSoundOthers",function(player,sound)
RemoteService.bounceOthers("Client",player,"PlayCharacterSoundOthers",sound)
end)
pcall(function()
TutorialService.listenConduit("Do","SetupTutorialTag",function(plr,matchType)
if TutorialService.hasMatchType(plr,matchType) then
local TTag = TutorialService.MakeTutorialTag(plr,matchType)
end
end)
end)
BindableService.listen("Send","AddKill",function(killed,killer,points)
KillService:AddKill(killed,killer,points)
end)
RemoteService.listen("Server","Fetch","RollForTrait",function(player,traitName)
return PlayerTraits[player.UserId][traitName]:Roll(player)
end)
RemoteService.listen("Server","Fetch","RollForTrait",function(player,traitName)
return PlayerTraits[player.UserId][traitName]:Roll(player)
end)
RemoteService.listen("Server","Fetch","HasTrait",function(player,traitName)
return Trait.HasTrait(player,PlayerTraits[player.UserId][traitName])
end)
BindableService.listen("Fetch","HasTrait",function(player,traitName)
return Trait.HasTrait(player,PlayerTraits[player.UserId][traitName])
end)
RemoteService.listen("Server","Fetch","GetAllTraits",function(player)
local result = {}
print(#Traits)
for _, trait in pairs(Traits) do
result[#result+1] = trait:ToReplicatedTrait()
end
return result
end)
RemoteService.listen("Server","Send","ChangePrimaryWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Primary then
PlayerLoadouts[plr.UserId].Primary:Destroy()
end
PlayerLoadouts[plr.UserId].Primary = weapon:Clone()
PlayerLoadouts[plr.UserId].Primary.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][1] = PlayerLoadouts[plr.UserId].Primary
end)
RemoteService.listen("Server","Send","ChangeSecondaryWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Secondary then
PlayerLoadouts[plr.UserId].Secondary:Destroy()
end
PlayerLoadouts[plr.UserId].Secondary = weapon:Clone()
PlayerLoadouts[plr.UserId].Secondary.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][2] = PlayerLoadouts[plr.UserId].Secondary
end)
RemoteService.listen("Server","Send","ChangeExplosiveWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Explosive then
PlayerLoadouts[plr.UserId].Explosive:Destroy()
end
PlayerLoadouts[plr.UserId].Explosive = weapon:Clone()
PlayerLoadouts[plr.UserId].Explosive.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][3] = PlayerLoadouts[plr.UserId].Explosive
end)
RemoteService.listen("Server","Send","ChangeGadgetWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Gadget then
PlayerLoadouts[plr.UserId].Gagdet:Destroy()
end
PlayerLoadouts[plr.UserId].Gadget = weapon:Clone()
PlayerLoadouts[plr.UserId].Gadget.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][4] = PlayerLoadouts[plr.UserId].Gadget
end)
RemoteService.listen("Server","Send","ChangeMeleeWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Melee then
PlayerLoadouts[plr.UserId].Melee:Destroy()
end
PlayerLoadouts[plr.UserId].Melee = weapon:Clone()
PlayerLoadouts[plr.UserId].Melee.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][5] = PlayerLoadouts[plr.UserId].Melee
end)
BindableService.listen("Send","ChangePrimaryWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Primary then
PlayerLoadouts[plr.UserId].Primary:Destroy()
end
PlayerLoadouts[plr.UserId].Primary = weapon:Clone()
PlayerLoadouts[plr.UserId].Primary.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][1] = PlayerLoadouts[plr.UserId].Primary
DataManager:SetLoadoutForSaving(plr,PlayerLoadouts[plr.UserId]:Serialize())
end)
BindableService.listen("Send","ChangeSecondaryWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Secondary then
PlayerLoadouts[plr.UserId].Secondary:Destroy()
end
PlayerLoadouts[plr.UserId].Secondary = weapon:Clone()
PlayerLoadouts[plr.UserId].Secondary.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][2] = PlayerLoadouts[plr.UserId].Secondary
end)
BindableService.listen("Send","ChangeExplosiveWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Explosive then
PlayerLoadouts[plr.UserId].Explosive:Destroy()
end
PlayerLoadouts[plr.UserId].Explosive = weapon:Clone()
PlayerLoadouts[plr.UserId].Explosive.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][3] = PlayerLoadouts[plr.UserId].Explosive
DataManager:SetLoadoutForSaving(plr,PlayerLoadouts[plr.UserId]:Serialize())
end)
BindableService.listen("Send","ChangeGadgetWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Gadget then
PlayerLoadouts[plr.UserId].Gagdet:Destroy()
end
PlayerLoadouts[plr.UserId].Gadget = weapon:Clone()
PlayerLoadouts[plr.UserId].Gadget.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][4] = PlayerLoadouts[plr.UserId].Gadget
end)
BindableService.listen("Send","ChangeMeleeWeapon",function(plr,weapon)
if PlayerLoadouts[plr.UserId].Melee then
PlayerLoadouts[plr.UserId].Melee:Destroy()
end
PlayerLoadouts[plr.UserId].Melee = weapon:Clone()
PlayerLoadouts[plr.UserId].Melee.Parent = plr.StarterGear
LoadoutWeapons[plr.UserId][5] = PlayerLoadouts[plr.UserId].Melee
end)
RemoteService.listen("Server","Send","ChangeCamo",function(player,gun,camo)
local Camo = InventoryService.Camo.FromReplicatedCamo(camo)
Camo:Apply(gun)
end)
RemoteService.listen("Server","Send","Deploy",function(plr)
plr:LoadCharacter()
end)
RemoteService.listen("Server","Fetch","GetLoadoutItem",function(plr,index)
return PlayerLoadouts[plr.UserId].CurrentItems[index]
end)
RemoteService.listen("Server","Send","AddItemToLoadout",function(player,slot,name)
local newItem = game.ReplicatedStorage.ITEMS:FindFirstChild(name,true):Clone()
newItem.Parent = player.Backpack
PlayerLoadouts[player.UserId]:SwitchTo(player,slot,newItem)
end)
BindableService.listen("Send","AddItemToLoadout",function(player,slot,name)
local newItem = game.ReplicatedStorage.ITEMS:FindFirstChild(name,true):Clone()
newItem.Parent = player.Backpack
PlayerLoadouts[player.UserId]:SwitchTo(player,slot,newItem)
end)
RemoteService.listen("Server","Send","EnterLoadoutMode",function(plr)
if plr.i8Mode.Value == "Loadout" then
PlayerLoadouts[plr.UserId]("equip",plr)
end
end)
BindableService.listen("Send","ResetPrimaryData",function(player)
DataManager:ResetPlayer(player,Starting)
end)
RemoteService.listen("Server","Send","Rebirth",function(player)
print("Resetting data for " .. player.Name .. "...")
CurrentJob[player.UserId] = createServerJob("ResetPlayerGame")
CurrentJob[player.UserId](true,player)
end)
BindableService.listen("Send","SetLoadoutItem",function(player,index,weapon)
PlayerLoadouts[player.UserId].CurrentItems[index] = weapon
end)
BindableService.listen("Fetch","GetAllItems",function(plr)
return PlayerLoadouts[plr.UserId].CurrentItems
end)
RemoteService.listen("Server","Fetch","GetAllItems",function(plr)
return PlayerLoadouts[plr.UserId].CurrentItems
end)
BindableService.listen("Send","EquipLoadout",function(plr)
if plr.i8Mode.Value == "Loadout" then
PlayerLoadouts[plr.UserId]("equip",plr)
end
end)
BindableService.listen("Fetch","CreateArchetypeQuest",function(aType,plr,...)
return QuestService:CreateFromArchetype(aType,plr,...)
end)
BindableService.listen("Send","BroadcastQuestToOwner",function(plr,qName)
QuestService:BroadcastToOwner(plr,qName)
end)
BindableService.listen("Send","CompleteObjective",function(plr,questName,objectiveName)
QuestService:MarkObjectiveAsComplete(plr,questName,objectiveName)
end)
BindableService.listen("Send","CompleteQuest",function(plr,qName)
QuestService:CompleteQuest(plr,qName)
end)
BindableService.listen("Fetch","HasQuest",function(plr,qName)
return QuestService:HasQuest(plr,qName)
end)
RemoteService.listen("Server","Fetch","GetPlayerAchievements",function(player)
local result = {}
for _, ach in pairs(AchievementCache[player.UserId]) do
result[#result+1] = ach:ToReplicatedAchievement()
end
return result
end)
BindableService.listen("Send","UpdateCEPlacement",function(player,placement,value)
DataManager:UpdateCurrentEquipmentPlacement(player,placement,value)
end)
RemoteService.listen("Server","Fetch","GetHighScores",function(player,threshold,scoreType)
return DataManager:LoadHighScores(scoreType,threshold)
end)
BindableService.listen("Send","ToggleCEPlacement",function(player,placement,on)
DataManager:ToggleCurrentEpuipmentPlacement(player,placement,on)
end)
BindableService.listen("Send","SetCurrentEPlacmenent",function(player,value)
DataManager:SetCurrentPlacement(player,value)
end)
BindableService.listen("Fetch","GetArmorWithPlacement",function(player,placement)
return DataManager:GetArmorWithPlacement(player,placement)
end)
BindableService.listen("Fetch","GetCurrentPlacement",function(player)
return DataManager:GetCurrentPlacement(player)
end)
RemoteService.listen("Server","Send","GiveAchievement",function(player,achId)
AchievementCache[player.UserId][achId]:Activate()
end)
BindableService.listen("Send","GiveAchievement",function(player,achId)
AchievementCache[player.UserId][achId]:Activate()
end)
RemoteService.listen("Server","Send","RunForceState",function(player,stateName,Vars)
if stateName then
local character = player.Character
if not character then return end
if Vars then
for name, var in pairs(Vars) do
ForceLib.ForceStates[player.UserId][stateName]:AddVar(name,var)
end
end
if player.Stats.Mana.Value >= ForceLib.ForceStates[player.UserId][stateName].ForceCost then
ForceLib.ForceStates[player.UserId][stateName].OnFire(character,ForceLib.ForceStates[player.UserId][stateName].Vars)
player.Stats.Mana.Value = player.Stats.Mana.Value - ForceLib.ForceStates[player.UserId][stateName].ForceCost
end
end
end)
RemoteService.listen("Server","Fetch","GetChatTags",function(plr)
return ChatTags[plr.UserId]
end)
BindableService.listen("Fetch","PowerEffect",function(base,AddPerInt,Offset,Int)
return RPGM.ForceMath.PowerEffect(base,AddPerInt,Offset,Int)
end)
BindableService.listen("Send","BreakWindow",function(hit)
if not hit then return end
local shat=Instance.new("Sound")
shat.SoundId="http://roblox.com/asset/?id=144884907"
shat.TimePosition = .1
shat.Parent = hit
shat:Play()
local sx,sy,sz=hit.Size.x,hit.Size.y,hit.Size.z
for x=1,4 do
for y=1,4 do
local part=hit:Clone()
local position=Vector3.new(x-2.1,y-2.1,0)*Vector3.new(sx/4,sy/4,sz)
part.Size=Vector3.new(sx/4,sy/4,sz)
part.CFrame=hit.CFrame*(CFrame.new(part.Size/8)-hit.Size/8+position)
part.Velocity=Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
-- for _, side in pairs({"Top","Bottom","Front","Back","Left","Right"}) do
-- part[side .. "Surface"] = Enum.SurfaceType.SmoothNoOutlines
-- end
part.Parent=workspace.ShatterIgnore
part.Name="Shatter"
debris:AddItem(part,2)
spawn(function()
wait(0.5)
for i=1,10 do
part.Transparency=part.Transparency+0.05
wait(0.05)
end
part:Destroy()
end)
part.Anchored=false
end
end
hit:Destroy()
end)
BindableService.listen("Fetch","PlayerList",function()
return Players
end)
local EvilStarships = {
"TIEFighter";
"TIEInterceptor";
}
local GoodStarships = {
"X-Wing";
"A-Wing";
}
local Units = {
"Assailant";
"HeavyAssailant";
"Sniper";
}
local MobSpawns = {
["Evil"] = {
["Assailant"] = {
CFrame.new(-34.13, -133.953, -1120.76);
CFrame.new(982.41, 36.388, -1196.96);
CFrame.new(982.41, 36.388, -1185.06);
CFrame.new(982.41, 36.388, -1169.43);
CFrame.new(-34.13, -133.953, -1153.72);
CFrame.new(-34.13, -133.953, -1162.1);
CFrame.new(-34.13, -133.953, -1147.46);
CFrame.new(-34.13, -133.953, -1129.14);
CFrame.new(-34.13, -133.953, -1114.5);
CFrame.new(6.7, -133.953, -1121.82);
CFrame.new(-7.94, -133.953, -1121.82);
};
["HeavyAssailant"] = {
CFrame.new(982.41, 37.388, -1196.96);
CFrame.new(982.41, 37.388, -1185.06);
CFrame.new(982.41, 37.388, -1169.43);
CFrame.new(-34.13, -132.953, -1153.72);
CFrame.new(-34.13, -132.953, -1162.1);
CFrame.new(-34.13, -132.953, -1147.46);
CFrame.new(-34.13, -132.953, -1129.14);
CFrame.new(-34.13, -132.953, -1120.76);
CFrame.new(-34.13, -132.953, -1114.5);
CFrame.new(0.44, -132.953, -1121.82);
CFrame.new(6.7, -132.953, -1121.82);
CFrame.new(-7.94, -132.953, -1121.82);
};
["Sniper"] = {
CFrame.new(1431.71, -103.072, -1114.98);
CFrame.new(482.67, -131.01, -735.231);
CFrame.new(651.19, -131.047, -922.18);
}
};
["Good"] = {
["Assailant"] = {
CFrame.new(-565.46, -133.953, -1084.89);
CFrame.new(-576.58, -133.953, -1028.94);
CFrame.new(-465.02, -133.953, -953.75);
CFrame.new(-622.71, -133.953, -1257.97);
CFrame.new(-724.52, -81.273, -1113.77);
CFrame.new(-440.77, -133.953, -1084.89);
};
["HeavyAssailant"] = {
CFrame.new(-540.02, -132.953, -1084.89);
CFrame.new(-594.74, -132.953, -1181.02);
CFrame.new(-564.49, -132.953, -1028.99);
CFrame.new(-492.73, -132.953, -941.61);
CFrame.new(-440.8, -132.953, -913.98);
CFrame.new(-533.52, -132.953, -942.08);
};
["Sniper"] = {
CFrame.new(-141.86, -133.93, -735.231);
CFrame.new(-34.13, -131.953, -1963.08);
CFrame.new(-368.57, -131.953, -1918.83);
CFrame.new(-973.81, -131.953, -1918.83);
}
}
}
local function SpawnUnit(Type,Side)
local Spawns = MobSpawns[Side][Type]
local Unit = game.ServerStorage.QuestModeUnitStorage:FindFirstChild(Side):FindFirstChild(Type):Clone()
Unit:SetPrimaryPartCFrame(Spawns[math.random(#Spawns)] + Vector3.new(0,3,0))
Unit.Parent = workspace.Mobs
end
local function SpawnUnitToKeep(Type,Side)
local Spawns = MobSpawns[Side][Type]
local Unit = game.ServerStorage.QuestModeUnitStorage:FindFirstChild(Side):FindFirstChild(Type):Clone()
Unit:SetPrimaryPartCFrame(Spawns[math.random(#Spawns)] + Vector3.new(0,3,0))
Unit.Parent = workspace.Mobs
return Unit
end
local function SpawnUnitRaw(Type,Side)
local Unit = game.ServerStorage.QuestModeUnitStorage:FindFirstChild(Side):FindFirstChild(Type):Clone()
return Unit
end
RemoteService.listen("Server","Fetch","IsServerStepCompleted",function(player,step)
if CurrentJob[player.UserId] ~= "None" then
if #CurrentJob[player.UserId].Steps > 0 then
local stepToUse = nil
for _ ,step2 in pairs(CurrentJob[player.UserId].Steps) do
if step2.Name == step then
stepToUse = step2
break
end
end
if stepToUse then
return stepToUse:IsFinished()
else
return false
end
else
return false
end
else
return false
end
end)
BindableService.listen("Send","SpawnScar",function(Type)
local Side = ((math.random(1,2) == 1) and "Good" or "Evil")
SpawnUnit(Units[math.random(#Units)],Side)
end)
BindableService.listen("Fetch","SpawnScarWithQuest",function(Type,Side)
local Unit = SpawnUnitToKeep(Type,Side)
Unit.QuestBorne.Value = true
return Unit
end)
BindableService.listen("Send","CreateSquadHealthBar",function(player,id,squadMember)
DataManager:CreateHBar(player,id,squadMember)
end)
BindableService.listen("Fetch","GetSquadAttrs",function(player,id)
return DataManager:GetSquadAttributes(player,id)
end)
BindableService.listen("Fetch","GetSquadHelmet",function(player,id)
return DataManager:GetSquadHelmet(player,id)
end)
BindableService.listen("Fetch","GetSquadWeapon",function(player,id)
return DataManager:GetSquadWeapon(player,id)
end)
BindableService.listen("Send","IncrementSquadAttributes",function(player,id,attr,amt)
DataManager:UpdateAttributes(player,id,attr,amt)
end)
BindableService.listen("Send","TickGrenade",function(nade)
local tInfo = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local props = {
PlaybackSpeed = 2;
}
local function numLerp(A, B, Alpha)
return A + (B - A) * Alpha
end
local tween = TweenService:Create(nade.PlantSound,tInfo,props)
nade.PlantSound.PlaybackSpeed = 1
tween:Play()
for i = 20, 1, -1 do
nade.PlantSound:Play()
wait(i/20)
end
end)
RemoteService.listen("Server","Send","SetDeploymentMethod",function(player,mode)
player.DeploymentMode.Value = mode
end)
TutorialService.startServer()
RemoteService.startServer()
BindableService.start()
local function SpawnTransport(side)
local Transport = game.ReplicatedStorage.AirSupport:FindFirstChild(side).AISpawnCraft:Clone()
end
local PatrolPoints = {
CFrame.new(180.145, -133.495, -1009.446);
CFrame.new(197.143, -134.499, -829.632);
CFrame.new(52.34, -133.742, -1169.978);
CFrame.new(-255.425, -133.498, -991.067);
CFrame.new(-623.593, -133.498, -1060.91);
CFrame.new(-164.734, -133.498, -1364.572);
CFrame.new(-428.462, -133.498, -991.067);
};
local FighterSpawns = {
["Good"] = {
CFrame.new(-1223.868, 103.633, 163.88);
CFrame.new(-1223.868, 103.633, 1003.623);
CFrame.new(-495.185, 103.633, 1003.623);
};
["Evil"] = {
CFrame.new(-191.255, 89.533, 3641.7);
CFrame.new(-982.521, 89.533, 703.008);
CFrame.new(-191.255, 89.533, 358.743);
CFrame.new(-578.351, 89.533, 1109.587);
CFrame.new(357.549, 89.533, 792.543);
CFrame.new(-1.015, 528.366, 117.371);
CFrame.new(550.576, 528.366, 103.59);
CFrame.new(1127.708, 528.366, -2492.922);
CFrame.new(-830.574, 528.366, -1938.873);
CFrame.new(-1910.214, 528.366, -1053.805);
}
}
local TankSpawns = {
["Evil"] = {
CFrame.new(-1071.626, -120.583, -1828.643);
CFrame.new(-849.536, -120.583, -1828.643);
CFrame.new(-644.996, -120.583, -1828.643);
CFrame.new(-467.016, -120.583, -1828.643);
CFrame.new(-64.926, -120.583, -1828.643);
};
["Good"] = {
CFrame.new(-40.305, -128.214, -1887.96);
}
}
local function SpawnStarFighter(shipType,...)
local shipTemp = game.ReplicatedStorage.AirSupport:FindFirstChild(shipType,true)
local ship = shipTemp:Clone()
local spawns = FighterSpawns[shipTemp.Parent.Name]
ship:SetPrimaryPartCFrame(spawns[math.random(#spawns)])
ship.Parent = workspace.Fighters:FindFirstChild(shipTemp.Parent.Name)
end
BindableService.listen("Fetch","GetPatrolPoints",function()
return PatrolPoints
end)
local ModifierWaitTimes = {
[1] = {
Time = 15;
State = false;
Action = function()
for i = 1, math.random(1,5) do
BindableService.send("SpawnScar",Units[math.random(#Units)])
wait(5)
end
end;
};
[2] = {
Time = 5;
State = false;
Action = function()
SpawnStarFighter(GoodStarships[math.random(#GoodStarships)])
end;
};
[3] = {
Time = 15;
State = false;
Action =function()
local Side = "Evil"
local enemies = {}
local count = math.random(1,5)
for i = 1, count do
enemies[#enemies+1] = SpawnUnitToKeep("HeavyAssailant",Side)
wait(3)
end
end;
};
[4] = {
Time = 15;
State = false;
Action = function()
end;
};
[5] = {
Time = 45;
State = false;
Action = function()
-- local AISpawnCraft = game.ReplicatedStorage.AirSupport.Evil.AISpawner.MAAT:Clone()
-- AISpawnCraft:SetPrimaryPartCFrame(FighterSpawns.Evil[math.random(#FighterSpawns.Evil)])
-- local Controller = require(AISpawnCraft.TransportController)
-- local seats = AISpawnCraft.Bodykit.TroopPlacement:GetChildren()
-- for i = 1, 4 do
-- local seat = seats[i]
-- if seat then
-- local unit = SpawnUnitRaw("Assailant","Evil")
-- unit.PrimaryPart.CFrame = seat.SkateboardPlatform.CFrame + Vector3.new(0,3,0)
-- unit.Parent = workspace.Mobs
-- Controller.Passengers[#Controller.Passengers+1] = unit
-- end
-- end
-- AISpawnCraft.Parent = workspace.Transports
-- Controller:StartEngine()
-- Controller:EnableAutoPilot()
-- Controller:TravelWithAutoPilot(PatrolPoints[math.random(#PatrolPoints)].p,function()
-- Controller:ReleasePassengers()
-- Controller:Takeoff(true)
-- end)
end;
};
[6] = {
Time = 25;
State = false;
Action = function()
local coords = PatrolPoints[math.random(#PatrolPoints)]
local shot = script.shot:Clone()
local range = 500
for i = 1,20 do
wait(.1)
local a = shot:Clone()
local preNewCoords = coords.p+Vector3.new(math.random(-range,range),1000,math.random(-range,range))
local _,newCoords = workspace:FindPartOnRay(Ray.new(preNewCoords,((preNewCoords-Vector3.new(0,1000,0))-preNewCoords).unit*2000))
a.Position = preNewCoords
a.ParticleEmitter:Emit(a:GetMass())
a.Parent = workspace:FindFirstChild('rayStorage') or workspace
local tween = TweenService:Create(a,TweenInfo.new(.6,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{Position = newCoords})
tween:Play()
delay(.55,function() a.Sound:Play() end)
debris:AddItem(a,.6)
tween.Completed:Connect(function()
local e = Instance.new('Explosion')
e.ExplosionType = Enum.ExplosionType.NoCraters
e.Position = newCoords
e.Parent = workspace
end)
end
end;
};
[7] = {
Time = 30;
State = false;
Action = function()
local enemy = nil
local Side = "Good"
local count = math.random(1, 5)
for i = 1, count do
BindableService.send("SpawnScar","Assailant")
wait(1)
end
end;
};
[8] = {
Time = 30;
State = false;
Action = function()
end;
};
[9] = {
Time = 5;
State = false;
Action = function()
end;
};
[10] = {
Time = 2.5;
State = false;
Action = function()
BindableService.send("SpawnScar",Units[math.random(#Units)])
end
};
[11] = {
Time = 2.5;
State = false;
Action = function()
for i = 1, 4 do
SpawnStarFighter(EvilStarships[math.random(#EvilStarships)])
end
end
};
[12] = {
Time = 30;
State = false;
Action = function()
for i = 1, math.random(5,10) do
BindableService.send("SpawnScar",Units[math.random(#Units)])
end
end;
};
[13] = {
Time = 45;
State = false;
Action = function()
for i = 1, math.random(5,10) do
SpawnStarFighter(EvilStarships[math.random(#EvilStarships)])
SpawnStarFighter(GoodStarships[math.random(#GoodStarships)])
end
end;
[14] = {
Time = 30;
State = false;
Action = function()
local Side = "Good"
local enemies = {}
local count = math.random(1,5)
for i = 1, count do
enemies[#enemies+1] = SpawnUnitToKeep("HeavyAssailant",Side)
wait(3)
end
end;
}
};
[15] = {
Time = 120;
State = false;
Action = function()
local Side = "Evil"
local enemy = game.ServerStorage.QuestModeUnitStorage:FindFirstChild(Side).Tank:Clone()
local Spawns = TankSpawns[Side]
local Spawn = Spawns[math.random(#Spawns)]
enemy:SetPrimaryPartCFrame(Spawn + Vector3.new(0,4,0))
enemy.Parent = workspace.Tanks
end;
};
[16] = {
Time = 20;
State = false;
Action = function()
local Side = "Evil"
local enemies = {}
local count = math.random(1,5)
for i = 1, count do
enemies[#enemies+1] = SpawnUnitToKeep("Assailant",Side)
wait(3)
end;
end;
};
[17] = {
Time = 25;
State = false;
Action = function()
local Side = "Good"
local enemies = {}
local count = math.random(1,5)
for i = 1, count do
enemies[#enemies+1] = SpawnUnitToKeep("Assailant",Side)
wait(3)
end
end;
};
[18] = {
Time = 30;
State = false;
Action = function()
local ammoModels = game.ReplicatedStorage.AmmoModels.Mags:GetChildren()
local ammo = ammoModels[math.random(#ammoModels)]:Clone()
local ammoSpawns = game.Workspace.AmmoSpawns:GetChildren()
local aSpawn = ammoSpawns[math.random(#ammoSpawns)]
local ammoInfo
if ammo:IsA("BasePart") then
ammo.CFrame = CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0);
ammoInfo = require(ammo.MagStats)
elseif ammo:IsA("Model") then
ammo:SetPrimaryPartCFrame(CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0));
ammoInfo = require(ammo.PrimaryPart.MagStats)
end
local ammoUI = MagInfo.GenerateUI()
ammoInfo:MakeUI(ammoUI.AmmoSpecs)
if ammo:IsA("BasePart") then
ammoUI.Parent = ammo
elseif ammo:IsA("Model") then
ammoUI.Parent = ammo.PrimaryPart
end
ammo.Parent = workspace.Loot.Ammo
end;
};
[19] = {
Time = 15;
State = false;
Action = function()
end;
};
[20] = {
Time = 20;
State = false;
Action = function()
local Side = "Evil"
local enemies = {}
local count = math.random(1,5)
for i = 1, count do
enemies[#enemies+1] = SpawnUnitToKeep("Assailant",Side)
wait(3)
end
end;
};
[21] = {
Time = 21;
State = false;
Action = function()
for i = 1,2 do
local ammoModels = game.ReplicatedStorage.AmmoModels.Mags:GetChildren()
local ammo = ammoModels[math.random(#ammoModels)]:Clone()
local ammoSpawns = game.Workspace.AmmoSpawns:GetChildren()
local aSpawn = ammoSpawns[math.random(#ammoSpawns)]
local ammoInfo
if ammo:IsA("BasePart") then
ammo.CFrame = CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0);
ammoInfo = require(ammo.MagStats)
elseif ammo:IsA("Model") then
ammo:SetPrimaryPartCFrame(CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0));
ammoInfo = require(ammo.PrimaryPart.MagStats)
end
local ammoUI = MagInfo.GenerateUI()
ammoInfo:MakeUI(ammoUI.AmmoSpecs)
if ammo:IsA("BasePart") then
ammoUI.Parent = ammo
elseif ammo:IsA("Model") then
ammoUI.Parent = ammo.PrimaryPart
end
ammo.Parent = workspace.Loot.Ammo
end
end
};
[22] = {
Time = 10;
State = false;
Action = function()
for i = 1,3 do
local ammoModels = game.ReplicatedStorage.AmmoModels.Mags:GetChildren()
local ammo = ammoModels[math.random(#ammoModels)]:Clone()
local ammoSpawns = game.Workspace.AmmoSpawns:GetChildren()
local aSpawn = ammoSpawns[math.random(#ammoSpawns)]
local ammoInfo
if ammo:IsA("BasePart") then
ammo.CFrame = CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0);
ammoInfo = require(ammo.MagStats)
elseif ammo:IsA("Model") then
ammo:SetPrimaryPartCFrame(CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0));
ammoInfo = require(ammo.PrimaryPart.MagStats)
end
local ammoUI = MagInfo.GenerateUI()
ammoInfo:MakeUI(ammoUI.AmmoSpecs)
if ammo:IsA("BasePart") then
ammoUI.Parent = ammo
elseif ammo:IsA("Model") then
ammoUI.Parent = ammo.PrimaryPart
end
ammo.Parent = workspace.Loot.Ammo
end
end
};
[23] = {
Time = 10;
State = false;
Action = function()
for i = 1,4 do
local ammoModels = game.ReplicatedStorage.AmmoModels.Mags:GetChildren()
local ammo = ammoModels[math.random(#ammoModels)]:Clone()
local ammoSpawns = game.Workspace.AmmoSpawns:GetChildren()
local aSpawn = ammoSpawns[math.random(#ammoSpawns)]
local ammoInfo
if ammo:IsA("BasePart") then
ammo.CFrame = CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0);
ammoInfo = require(ammo.MagStats)
elseif ammo:IsA("Model") then
ammo:SetPrimaryPartCFrame(CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0));
ammoInfo = require(ammo.PrimaryPart.MagStats)
end
local ammoUI = MagInfo.GenerateUI()
ammoInfo:MakeUI(ammoUI.AmmoSpecs)
if ammo:IsA("BasePart") then
ammoUI.Parent = ammo
elseif ammo:IsA("Model") then
ammoUI.Parent = ammo.PrimaryPart
end
ammo.Parent = workspace.Loot.Ammo
end
end
};
[24] = {
Time = 20;
State = false;
Action = function()
for i = 1,5 do
local ammoModels = game.ReplicatedStorage.AmmoModels.Mags:GetChildren()
local ammo = ammoModels[math.random(#ammoModels)]:Clone()
local ammoSpawns = game.Workspace.AmmoSpawns:GetChildren()
local aSpawn = ammoSpawns[math.random(#ammoSpawns)]
local ammoInfo
if ammo:IsA("BasePart") then
ammo.CFrame = CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0);
ammoInfo = require(ammo.MagStats)
elseif ammo:IsA("Model") then
ammo:SetPrimaryPartCFrame(CFrame.new(aSpawn.CFrame.p)*CFrame.new(math.random(-20, 20)/10, 0, math.random(-20, 20)/10)*CFrame.Angles(0, math.rad(math.random(0, 359)), 0));
ammoInfo = require(ammo.PrimaryPart.MagStats)
end
local ammoUI = MagInfo.GenerateUI()
ammoInfo:MakeUI(ammoUI.AmmoSpecs)
if ammo:IsA("BasePart") then
ammoUI.Parent = ammo
elseif ammo:IsA("Model") then
ammoUI.Parent = ammo.PrimaryPart
end
ammo.Parent = workspace.Loot.Ammo
end
end
};
[25] = {
Time = 15;
State = false;
Action = function()
SpawnStarFighter(EvilStarships[math.random(#EvilStarships)])
end;
}
}
spawn(function()
while wait(math.random(5,15)) do
local modifier = math.random(1,#ModifierWaitTimes)
print("Unit Modifier: " .. modifier)
spawn(function()
if (not ModifierWaitTimes[modifier].State) then
ModifierWaitTimes[modifier].State = true
ModifierWaitTimes[modifier].Action()
wait(ModifierWaitTimes[modifier].Time)
ModifierWaitTimes[modifier].State = false
end
end)
end
end)
end
local Gun = script.Parent
local DamageTag = require(game.ReplicatedStorage.DamageTag)
local TweenService = game:GetService("TweenService")
game.CollectionService:AddTag(Gun,game.HttpService:GenerateGUID(false))
game.CollectionService:AddTag(Gun,"Weapon")
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local Handle = Gun.Handle
local Character = Gun.Parent
local Sequences = {
Color = ColorSequence.new;
Number = NumberSequence.new;
}
local CF = {
RAW = CFrame.new;
ANG = CFrame.Angles;
AA = CFrame.fromAxisAngle;
COMP = CFrame.new().components;
OBJSPACE = CFrame.new().toObjectSpace;
Lerp = CFrame.new().lerp;
ID = CFrame.new();
AIMORIGIN = function(Aimed,settings,Flash)
return ((Aimed and settings.sniperScope) and Character.Head.CFrame or Flash.CFrame)
end
}
local SIN = math.sin;
local COS = math.cos;
local TAN = math.tan;
local ARCCOS = math.acos;
local ATAN2 = math.atan2
local ATAN = math.atan
local ARCSIN = math.asin;
local Equipped = false
local Bot = require(Character.BOT)
local settings = require(Gun.SETTINGS)
local force
local WS = workspace
local RS = game:GetService("RunService")
local AttributeEffect =require(WS.Settings.AttributeEffect)
local PerLevel = require(WS.Settings.PerLevel)
local RPGM = require(game.ReplicatedStorage.RPGMathProvider)
local Detonator = require(game.ReplicatedStorage.GunLibraries.Detonator)
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local Increment = 90 / 0.4--1.5 / 0.4
local currentlyCrawling = false
local crawlTween = false
local onGround = true
local canFire = true
local startFallHeight = 0
local runReady = true
local StanceFunctions = {}
PenetrationTries = settings.penetrationSettings.maxTries
local CharParts = {
Head = Character:WaitForChild("Head",200),
LeftLeg = Character:WaitForChild("Left Leg",200),
RightLeg = Character:WaitForChild("Right Leg",200),
Torso = Character:WaitForChild("Torso",200),
RightArm = Character:WaitForChild("Right Arm",200),
LeftArm = Character:WaitForChild("Left Arm",200),
HRP = Character:WaitForChild("HumanoidRootPart",200)
}
local CharJoints = {
Root = CharParts.HRP:WaitForChild("RootJoint",200);
LeftHip = CharParts.Torso:WaitForChild("Left Hip",200);
RightHip = CharParts.Torso:WaitForChild("Right Hip",200);
LeftShoulder = CharParts.Torso:FindFirstChild("Left Shoulder");
RightShoulder = CharParts.Torso:FindFirstChild("Right Shoulder");
}
local maxStamina = settings.sprintTime * 60
local runKeyPressed = false
local chargingStamina = false
local MobFolder = nil
local Stamina = settings.sprintTime * 60
local Humanoid = Character.Human
local OBJ = Instance.new
local VEC2 = Vector2.new
local LWeld2, RWeld2
local RAD = function(angle)
return angle * (math.pi/180)
end
local CEIL,ABS = math.ceil,math.abs
local Ignore = {
Character;
}
local leftCrouchWeld,rightCrouchWeld
local Speed = 0
local PrimitiveAnim = require(game.ReplicatedStorage.GunLibraries.PrimitiveAnim)
local Firing = false
local spreadMotion = "Idling"
local leftWeld = nil
local rightWeld = nil
local headWeld = nil
local ABWeld = nil
local animWeld = nil
local unAimedC1Grip = nil
local headWeld2 = nil
local headBase = nil
local translationDivisor = 7
local spreads = {
base = settings.spreadSettings.unAimed.Stand.Idling;
current = 0;
}
local loweringSpread = false
local crawlCamRot = 0
local Stance = 0
local animCode = 0
local ammoInClip = 0
local Connections = {}
local Reloading = false
local function DisplayDamage(damage,humanoid)
local part2 = OBJ("TextLabel")
part2.Font = "SciFi"
part2.FontSize = "Size24"
part2.TextStrokeTransparency = 0
part2.Size = UDim2.new(1,0,1,0)
part2.Position = UDim2.new(0,0,0,0)
part2.BackgroundTransparency = 1
part2.Parent = humanoid.Parent.Head.DamageGUI
spawn(function()
if part2 then
part2:TweenPosition(UDim2.new(0,0,0,-98))
wait(1)
for i = 1, 20 do
part2.TextTransparency = part2.TextTransparency + 0.05
wait(0.025)
end
end
end)
if (damage == 0) then
part2.TextColor3 = Color3.new(0,0.5,1)
part2.Text = "Miss!"
else
part2.TextColor3 = Color3.new(1,1,1)
part2.Text = damage
end
end
local INSERT = function(tableObj,item)
tableObj[#tableObj+1] = item
end
local REMOVE = function(tableObj,i)
tableObj[i] = nil
end
local RAY = {
RAW = Ray.new;
CAST = workspace.FindPartOnRayWithIgnoreList;
}
local Sine = function(X)
return SIN(RAD(X))
end
local lDH = nil
local Linear = function(X)
return (X * 0.0111111111111)
end
local inList = function(Element, List)
for _, v in pairs(List) do
if v == Element then
return true
end
end
return false
end
local getObject = function(Model, Class, Name)
for _, v in pairs(Model:GetChildren()) do
if v:IsA(Class) and v.Name == Name then
return v
end
end
return nil
end
local function tagHumanoid(humanoid,dmg)
local tag = DamageTag.new((game.Players:GetPlayerFromCharacter(humanoid.Parent) and game.CollectionService:GetTags(game.Players:GetPlayerFromCharacter(humanoid.Parent))[1] or game.CollectionService:GetTags(humanoid.Parent)[1]),dmg,game.CollectionService:GetTags(Gun)[1],game.CollectionService:GetTags(Character)[1])
tag:MarkEnemy(humanoid)
end
local V3,RANDOM = Vector3.new,math.random
local V3Straight = V3(1,0,1)
local MIN = math.min
local FLOOR = math.floor
local Flash = Gun.Flash
local armC0 = {
CF.RAW(-1.5, 0, 0) * CF.ANG(RAD(90), 0, 0);
CF.RAW(1.5, 0, 0) * CF.ANG(RAD(90), 0, 0);
}
local legC0 = {
Stand = {
CF.RAW(-0.5, -2, 0);
CF.RAW(0.5, -2, 0);
};
Crouch = {
CF.RAW(-0.5, -1.5, 0.5) * CF.ANG(-RAD(90), 0, 0);
CF.RAW(0.5, -1, -0.75);
};
Prone = {
CF.RAW(-0.5, -2, 0);
CF.RAW(0.5, -2, 0);
};
}
local camOffsets = {
guiScope = PrimitiveAnim.new(V3());
Reload = PrimitiveAnim.new(V3(),nil);
Recoil = PrimitiveAnim.new(V3(),nil);
};
local Signal = require(game.ReplicatedStorage.SignalAPI)
local Anims = require(Gun.ANIMATIONS)
local GunMath = {}
local Spring = require(game.ReplicatedStorage.GunLibraries.Spring)
local spreadZoom = "unAimed"
local spreadStance = "Stand"
local CamRecoilSpring = Spring.new(V3())
CamRecoilSpring.s = 35
CamRecoilSpring.d = 0.5
local camAng = VEC2(0,0)
local aimHeadOffset = 0;
local aimAlpha = 0;
local crawlAlpha = 0;
local idleAlpha = 1;
local runAlpha = 0;
local walkAlpha = 0;
local Recoil = {
Pos = V3();
Rot = V3();
Code = 0;
};
local RecoilSpring = Spring.new(V3());
RecoilSpring.s = settings.recoilSettings.springSpeed;
RecoilSpring.d = settings.recoilSettings.springDamper;
armTiltMultiplier = 1;
local Speed = 16;
local crawlCamRot = 0;
local Aimed = false;
local isWalking = false;
local isIdling = true;
local isCrawling = false;
local isRunning = false;
Signals = {
AimChanged = Signal.Create();
};
local stanceSway = 1;
local camSway = 1;
local BasePose = PrimitiveAnim.new(V3(),0,V3(),0);
local headOffset = VEC2(COS(RAD(90) - settings.aimSettings.headTilt) * 0.5, 1 + SIN(RAD(90) - settings.aimSettings.headTilt) * 0.5)
local moveAng = 0
local armTilt = 0
GunMath.Map = function(Val, fromLow, fromHigh, toLow, toHigh)
return (Val - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow
end
local firstShot = false
local shotCount = 0
local lastSideRecoil = {0, 0}
local function Lerp(A, B, Alpha)
return A + (B - A) * Alpha
end
GunMath.RAND = function(Min, Max, Accuracy)
return Lerp(Min, Max, RANDOM())
--[[local Inverse = 1 / (Accuracy or 1)
return (math.random(Min * Inverse, Max * Inverse) / Inverse)]]
end
GunMath.Round = function(Num, toNearest)
return FLOOR(Num / toNearest + 0.5) * toNearest
end
GunMath.getNearestPoint = function(A, B, Origin)
local A2 = (A - Origin).magnitude
local B2 = (B - Origin).magnitude
return (MIN(A2, B2) == A2 and A or B)
end
local getYawPitch = function(Cf)
local LV = Cf.lookVector
local Yaw = ATAN2(LV.x, -LV.z)
local Pitch = ARCSIN(-LV.Y)
return Yaw, Pitch
end
local function getTotalCamOffsets()
return camOffsets.guiScope.Rot + camOffsets.Reload.Rot + CamRecoilSpring.p
end
local function isEnemy(Human)
local Plyr2 = game.Players:GetPlayerFromCharacter(Human.Parent)
if (not Plyr2) then if settings.CanDamageNPCs then
if Human.Parent:FindFirstChild("BOT") then
return (require(Human.Parent.BOT).Allegiance ~= Bot.Allegiance)
end
end
end
return settings.AllowFriendlyFire or (Plyr2 ~= nil and (Plyr2.Allegiance.Value ~= Bot.Allegiance or Plyr2.Neutral))
end
local function tagSelf(humanoid, player, damage, previousHealth)
local creator_tag = OBJ("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = Humanoid
local damage_tag = OBJ("IntValue", creator_tag)
if humanoid.Health < 1 then
damage_tag.Value = CEIL(previousHealth)
else
damage_tag.Value = CEIL(damage)
end
damage_tag.Name = "damage"
end
local magTrans = {}
do
local gunParts = {}
for _, v in pairs(Gun:GetChildren()) do
if v:IsA("BasePart") and v ~= Handle then
if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end
if v.Name:sub( 1, 3) == "Mag" then
magTrans[#magTrans+1] = {Obj = v,Trans = v.Transparency}
end
v.Anchored = true
v.CanCollide = false
end
end
Handle.Anchored = false
Handle.CanCollide = true
for i, v in pairs(Gun:GetChildren()) do
if v:IsA("BasePart") and v ~= Handle then
INSERT(gunParts, {Obj = v, Weld = nil, WeldCFrame = Handle.CFrame:toObjectSpace(v.CFrame)})
v.Anchored = false
end
end
for _, Tab in pairs(gunParts) do
local Weld = Instance.new("Weld")
Weld.Name = "MainWeld"
Weld.Part0 = Handle
Weld.Part1 = Tab.Obj
Weld.C0 = Tab.WeldCFrame
Weld.Parent = Handle
Tab.Weld = Weld
end
end
function tween(...)
local args = {...}
if args then
if args[1] == "Joint" then
local Joint = args[2]
local newC0 = args[3]
local newC1 = args[4]
local Alpha = args[5]
local Duration = args[6]
spawn(function()
if Duration <= 0 then --If the duration is less than or equal to 0 then there's no need for a tweening loop
if newC0 then Joint.C0 = newC0 end
if newC1 then Joint.C1 = newC1 end
else
local startC0 = Joint.C0
local startC1 = Joint.C1
local tInfo = TweenInfo.new(Duration,Alpha)
local props = {
C0 = newC0;
C1 = newC1;
}
local TweenObj = TweenService:Create(Joint,tInfo,props)
TweenObj:Play()
TweenObj.Completed:wait()
end
end)
end
if args[1] == "Cam" then
local Key = args[2]
local newRot = args[3]
local Alpha = args[4]
local Duration = args[5]
spawn(function()
local newCode = RANDOM(-1e9, 1e9)
camOffsets[Key].Code = newCode
local Increment = 1.5 / Duration
local prevRot = camOffsets[Key].Rot
local X = 0
while true do
wait(1/60)
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if camOffsets[Key].Code ~= newCode then break end
--if (not Selected) then break end
camOffsets[Key].Rot = prevRot:lerp(newRot, Alpha(X))
CamRecoilSpring.t = camOffsets.Recoil.Rot
if X == 90 then break end
end
if camOffsets[Key].Code == newCode then
camOffsets[Key].Code = nil
end
end)
end
if args[1] == "Recoil" then
local newPos = args[2]
local newRot = args[3]
local Alpha = args[4]
local Duration = args[5]
spawn(function()
local newCode = RANDOM(-1e9, 1e9)
Recoil.Code = newCode
local Increment = 1.5 / Duration
local prevPos = Recoil.Pos
local prevRot = Recoil.Rot
local X = 0
while true do
wait(1/60)
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if Recoil.Code ~= newCode then break end
--if (not Selected) then break end
Recoil.Pos = prevPos:lerp(newPos, Alpha(X))
Recoil.Rot = prevRot:lerp(newRot, Alpha(X))
RecoilSpring.t = Recoil.Rot
if X == 90 then break end
end
if Recoil.Code == newCode then
Recoil.Code = nil
end
end)
end
if args[1] == "Aim" then
local frames = args[2]
local Alpha = args[3]
local aimingIn = args[4]
local t0 = tick()
while true do
wait(1/60)
local X = MIN((tick() - t0) / frames, 1) * 90
if aimingIn then
aimAlpha = Alpha(X)
else
aimAlpha = 1 - Alpha(X)
end
aimHeadOffset = headOffset.X * aimAlpha
translationDivisor = Lerp(7, 20, aimAlpha)
armTiltMultiplier = Lerp(1, 0.2, aimAlpha)
if X == 90 then break end
end
end
end
end
function renderCamera()
local finalCamOffset = getTotalCamOffsets()
Character.MobCam.CameraType = Enum.CameraType.Scriptable
Character.MobCam.CFrame = CF.RAW(Character.Head.CFrame.p,Gun.TargetCFrame.Value.p)
--Character.MobCam:SetRoll(crawlCamRot + finalCamOffset.Z)
end
local function Damage(H, P, N, D, Dist, customIgnore)
if not H then return end;
if not H.Parent then return end;
local hVal = settings.damageSettings.Multipliers.Head
local cVal = settings.damageSettings.Multipliers.Chest
local lVal = settings.damageSettings.Multipliers.Limbs
if Humanoid.Health ~= 0 then
local hitHumanoid = nil
if H.Parent then
if H.Parent:IsA("Hat") then
INSERT(customIgnore, H)
local newRay = RAY.RAW(P - D * 0.1, D * (settings.bulletSettings.Range - Dist + 0.1))
local newH, newP, newN = RAY.CAST(workspace,newRay, customIgnore)
if newH then
hitHumanoid = Damage(newH, newP, newN, D, Dist + (newP - P).magnitude, customIgnore)
end
else
hitHumanoid = H.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
local chosenDamage = 0
if H.Name == "Head" then
chosenDamage = RPGM.RangedCombatMath.HeadShotDamageAI(Gun.Damage.Value,Gun.HeadshotDamageMagnitude.Value)
elseif H.Name == "Torso" then
chosenDamage = (RPGM.RangedCombatMath.TorsoDamageAI(Gun.Damage.Value,Bot,AttributeEffect,PerLevel))
else
chosenDamage = (RPGM.RangedCombatMath.RegularDamageAI(Gun.Damage.Value,Bot,AttributeEffect,PerLevel))
end
local sniperRand
if H.Name == "Head" and settings.sniperDamage then
sniperRand = RANDOM(1,2)
chosenDamage = (sniperRand == 2 and hitHumanoid.Health or chosenDamage)
end
local damageHum = 0
if hitHumanoid.Parent:FindFirstChild("SwordScript",true) then
if hitHumanoid.Parent:FindFirstChild("SwordScript",true).Parent:FindFirstChild("Deflecting") then
if hitHumanoid.Parent:FindFirstChild("SwordScript",true).Parent:FindFirstChild("Deflecting").Value then
damageHum = RANDOM(1,20)
end
end
end
if damageHum % 4 == 0 then
hitHumanoid:TakeDamage(chosenDamage)
tagHumanoid(hitHumanoid,chosenDamage)
elseif damageHum % 4 > 0 then
tagSelf(Humanoid, (game.Players:GetPlayerFromCharacter(hitHumanoid.Parent) and game.Players:GetPlayerFromCharacter(hitHumanoid.Parent) or hitHumanoid.Parent), chosenDamage*2, Humanoid.Health)
Humanoid:TakeDamage(chosenDamage*2)
script.DeflectionSound:Play()
else
hitHumanoid:TakeDamage(chosenDamage)
tagHumanoid(hitHumanoid,chosenDamage)
H:FindFirstChild("HitMarker").Value = H:FindFirstChild("HitMarker").Value + chosenDamage
end
if hitHumanoid.Parent.Head:FindFirstChild("DamageGUI") then
--DisplayDamage(chosenDamage,hitHumanoid)
end
if not game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)and hitHumanoid.Name == "Human" then
-- game.ReplicatedStorage.RemoteService.MobHitWithRangedWeapon:FireServer(hitHumanoid)
end
return hitHumanoid
end
end
end
end
end
local function MakeHole(H,P,N,humanoidFound)
local surfaceCF =CF.RAW(P, P + N)
----------------------------------------------------------------------------------
--Creating the bullet hole--------------------------------------------------------
----------------------------------------------------------------------------------
pcall(function()
if settings.bulletHoles and ((not humanoidFound)) then
local Hole = OBJ("Part")
Hole.Transparency = 1
Hole.Anchored = true
Hole.CanCollide = false
Hole.FormFactor = "Custom"
Hole.Size = V3(1, 1, 0.2)
Hole.TopSurface = 0
Hole.BottomSurface = 0
local Mesh = OBJ("BlockMesh")
Mesh.Offset = V3(0, 0, -0.05)
Mesh.Scale = V3(settings.holeSettings.Size, settings.holeSettings.Size, 0)
Mesh.Parent = Hole
local Decal = OBJ("Decal")
Decal.Face = Enum.NormalId.Front
Decal.Texture = settings.holeSettings.Texture
Decal.Parent = Hole
Hole.Parent = Gun.HoleStorage.Value
Hole.CFrame = surfaceCF
if not H.Anchored then
local Weld = OBJ("Motor6D")
Weld.Part0 = H
Weld.Part1 = Hole
Weld.C0 = CF.OBJSPACE(H.CFrame,surfaceCF)
Weld.Parent = Hole
Hole.Anchored = false
end
game.Debris:AddItem(Hole,settings.holeSettings.visibleTime + settings.holeSettings.disappearTime)
end
end)
----------------------------------------------------------------------------------
--Creating the spark effect-------------------------------------------------------
----------------------------------------------------------------------------------
pcall(function()
if settings.bulletSparks and (not humanoidFound) and inList(H.Material, settings.sparkSettings.Materials) then
local Sparks = OBJ("Part")
Sparks.Transparency = 1
Sparks.Anchored = true
Sparks.CanCollide = false
Sparks.FormFactor = "Custom"
Sparks.Size = V3(1, 1, 1)
Sparks.TopSurface = 0
Sparks.BottomSurface = 0
local Particles = nil
if settings.customSparks then
Particles = game.ServerStorage.bulletSpark:Clone()
else
Particles = OBJ("ParticleEmitter")
Particles.Color = Sequences.Color(settings.sparkSettings.Color.Start, settings.sparkSettings.Color.End)
Particles.LightEmission = 1
Particles.Size = Sequences.Number(
{
Sequences.Keypoints.Number(0, settings.sparkSettings.Size, 0.25);
Sequences.Keypoints.Number(1, 0);
}
)
Particles.Texture = settings.sparkSettings.Texture
Particles.Transparency = Sequences.Number(0)
Particles.Acceleration = V3(0, -196.2, 0)
Particles.EmissionDirection = Enum.NormalId.Front
Particles.Lifetime = NumberRange.new(settings.sparkSettings.Lifetime - 0.05, settings.sparkSettings.Lifetime + 0.05)
Particles.Rate = settings.sparkSettings.Rate
Particles.Rotation = NumberRange.new(0, 360)
Particles.Speed = NumberRange.new(settings.sparkSettings.Speed - 5, settings.sparkSettings.Speed + 5)
Particles.VelocitySpread = settings.sparkSettings.Spread
end
Particles.LockedToPart = true
Particles.Parent = Sparks
Particles.Enabled = false
Sparks.Parent = Gun.HoleStorage.Value
Sparks.CFrame = surfaceCF
if not H.Anchored then
local Weld = OBJ("Motor6D")
Weld.Part0 = H
Weld.Part1 = Sparks
Weld.C0 = CF.OBJSPACE(H.CFrame,surfaceCF)
Weld.Parent = Sparks
Sparks.Anchored = false
end
Particles:Emit(5)
wait(1)
Sparks:Destroy()
end
end)
----------------------------------------------------------------------------------
--Creating the smoke effect-------------------------------------------------------
----------------------------------------------------------------------------------
pcall(function()
if settings.bulletSmoke and (not humanoidFound) then
local Smoke = OBJ("Part")
Smoke.Transparency = 1
Smoke.Anchored = true
Smoke.CanCollide = false
Smoke.FormFactor = "Custom"
Smoke.Size = V3(1, 1, 1)
Smoke.TopSurface = 0
Smoke.BottomSurface = 0
local Particles = OBJ("ParticleEmitter")
Particles.LockedToPart = true
Particles.Color = Sequences.Color(settings.smokeSettings.objColor and H.Color or settings.smokeSettings.Color)
Particles.LightEmission = 0
Particles.Size = Sequences.Number(
{
NumberSequenceKeypoint.new(0, settings.smokeSettings.Size.Start);
NumberSequenceKeypoint.new(1, settings.smokeSettings.Size.End);
}
)
Particles.Texture = settings.smokeSettings.Texture
Particles.Transparency = Sequences.Number(
{
NumberSequenceKeypoint.new(0, settings.smokeSettings.startTransparency);
NumberSequenceKeypoint.new(0.5, 0.75 * settings.smokeSettings.startTransparency + 0.25);
NumberSequenceKeypoint.new(1, 1);
}
)
Particles.Acceleration = V3(0, -196.2, 0)
Particles.EmissionDirection = Enum.NormalId.Front
Particles.Lifetime = NumberRange.new(settings.smokeSettings.Lifetime - 0.05, settings.smokeSettings.Lifetime + 0.05)
Particles.Rate = settings.smokeSettings.Rate
Particles.Rotation = NumberRange.new(0, 360)
Particles.RotSpeed = NumberRange.new(10)
Particles.Speed = NumberRange.new(settings.smokeSettings.Speed - 5, settings.smokeSettings.Speed + 5)
Particles.VelocitySpread = settings.smokeSettings.Spread
Particles.Parent = Smoke
Particles.Enabled = false
Smoke.Parent = Gun.HoleStorage.Value
Smoke.CFrame = surfaceCF
if not H.Anchored then
local Weld = OBJ("Motor6D")
Weld.Part0 = H
Weld.Part1 = Smoke
Weld.C0 = CF.OBJSPACE(H.CFrame,surfaceCF)
Weld.Parent = Smoke
Smoke.Anchored = false
end
Particles:Emit(15)
wait(1)
Smoke:Destroy()
end
end)
end
function lowerSpread()
if (not loweringSpread) then
loweringSpread = true
local Connection = nil
Connection = RS.Heartbeat:connect(function(dt)
if Character.Shooting.Value then
Connection:disconnect()
end
local newSpread = spreads.current - (settings.spreadSettings.Decrease * dt)
spreads.current = (newSpread < 0 and 0 or newSpread)
if spreads.current == 0 then
Connection:disconnect()
end
end)
loweringSpread = false
end
end
function removeElement(Table, Element) --removes the first instance of Element from Table
for i, v in pairs(Table) do
if v == Element then
REMOVE(Table, i)
break
end
end
return Table
end
function isIgnored(Obj, Table)
for _,v in pairs(Table) do
if Obj == v or Obj:IsDescendantOf(v) then
return true
end
end
return false
end
function isWallIgnored(Wall)
return (
Wall.Transparency >= settings.penetrationSettings.transparencyThreshold or
(settings.penetrationSettings.ignoreNonCanCollide and (not Wall.CanCollide)) or
isIgnored(Wall, settings.penetrationSettings.ignoreCustom) or (not game.PhysicsService:CollisionGroupContainsPart("CoverPoints",Wall))
)
end
function penetrateWall(Wall, hitPos, Direction, Normal, Ignore, totalPDist, totalBDist, lastDamagedHumanoid)
local wallIgnore = isWallIgnored(Wall)
local hitHumanoid = Damage(Wall, hitPos, Normal, Direction, totalBDist, {Character})
local damagedHumanoid = nil
if hitHumanoid and hitHumanoid ~= lastDamagedHumanoid then
lastDamagedHumanoid = hitHumanoid
damagedHumanoid = Damage(Wall, hitPos, Normal, Direction, totalBDist, {Character})
if damagedHumanoid ~= nil then
lDH = damagedHumanoid
end
else
lastDamagedHumanoid = nil
-- DamageVehicle(Wall,totalBDist)
if Wall.Name == "Window" then
--Libraries.Network.send("Server","BreakWindow",Wall, workspace)
end
end
local ignoreObject = hitHumanoid and (Wall.Parent:IsA("Hat") and Wall.Parent.Parent or Wall.Parent) or Wall
INSERT(Ignore, ignoreObject)
local rayLength = settings.bulletSettings.Range - totalBDist
local testRay = RAY.RAW(hitPos, Direction * (settings.bulletSettings.Range - totalBDist))
local H1, P1, N1 = RAY.CAST(WS,testRay, Ignore)
local newIgnore = removeElement(Ignore, ignoreObject)
local wallRay = RAY.RAW(P1 + Direction * 0.1, -Direction * (rayLength + 1))
local H2, P2, N2 = RAY.CAST(WS,wallRay, Ignore)
local newPDist = totalPDist + (wallIgnore and 0 or (GunMath.getNearestPoint(P1, P2, hitPos) - hitPos).magnitude)
local newBDist = totalBDist + (P1 - hitPos).magnitude
local outOfRange = GunMath.Round(newPDist, 0.001) > settings.penetrationSettings.Dist or GunMath.Round(newBDist, 0.001) > settings.bulletSettings.Range
if (not wallIgnore) then
MakeHole(Wall,P2,N2,hitHumanoid)
if (not hitHumanoid) then
--Libraries.Network.send("Server","Shockwave_"..Player.UserId,hitPos, S.shockwaveSettings.Radius, gunIgnore, S)
end
end
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) and hitHumanoid == damagedHumanoid then
--Libraries.Network.fetch("Server","Blood_"..Player.UserId,Wall, P2, Direction, gunIgnore, S)
end
if outOfRange or (not H1) then
if (not outOfRange) and (not wallIgnore) then
MakeHole(Wall,P2,N2,hitHumanoid)
if (not hitHumanoid) then
--Libraries.Network.send("Server","Shockwave_"..Player.UserId,P2, S.shockwaveSettings.Radius, gunIgnore, S)
end
end
return Wall, hitPos
else
if Wall == H2 and (not wallIgnore) then
MakeHole(Wall,P2,N2,hitHumanoid)
if (not hitHumanoid) then
-- Libraries.Network.send("Server","Shockwave_"..Player.UserId,P2, S.shockwaveSettings.Radius, gunIgnore, S)
end
end
PenetrationTries = PenetrationTries - 1
if PenetrationTries ~= 0 then
return penetrateWall(H1, P1, Direction, N1, Ignore, newPDist, newBDist, lastDamagedHumanoid)
else
PenetrationTries = settings.penetrationSettings.maxTries
return nil
end
end
end
Gun.lowerSpread.Event:connect(lowerSpread)
function animateReload()
local magParts = {}
local magTable = {}
for _, Obj in pairs(Gun:GetChildren()) do
if string.sub(Obj.Name, 1, 3) == "Mag" and Obj:IsA("BasePart") then
INSERT(magParts, Obj)
end
end
local findMagTrans = function(magPart)
local result = nil
for _, magTransObj in pairs(magTrans) do
if magTransObj.Obj == magPart then
result = magTransObj
end
end
return result
end
local animVars = {
--FUNCTIONS--
tweenJoint = function(Joint, newC0, newC1, Alpha, Duration)
tween("Joint",Joint,newC0,newC1,Alpha,Duration)
end;
tweenRecoil = function(Pos, Rot, Alpha, Duration)
tween("Recoil" , Pos, Rot, Alpha, Duration)
end;
makeMagInvisible = function()
for _, v in pairs(magParts) do
v.Transparency = 1
end
magVisible = false
end;
makeMagVisible = function()
for _, v in pairs(magParts) do
v.Transparency = findMagTrans(v).Trans
end
magVisible = true
end;
isMagVisible = function()
return magVisible
end;
isMagEmpty = function()
return ammoInClip == 0
end;
setNewMag = function()
newMag = true
end;
isNewMag = function()
return newMag
end;
createMag = function(Key)
local magModel = Instance.new("Model")
local magClones = {}
for i, v in pairs(magParts) do
local vClone = v:Clone()
vClone.Transparency = findMagTrans(v).Trans
vClone.CanCollide = false
vClone.Parent = magModel
INSERT(magClones, {Original = v, magClone = vClone})
if i ~= 1 then
local W = Instance.new("Motor6D")
W.Part0 = magClones[1].magClone
W.Part1 = vClone
W.C0 = CF.OBJSPACE(magClones[1].magClone.CFrame,vClone.CFrame)
W.Parent = magClones[1].magClone
end
end
magTable[Key] = {magModel, magClones}
return magModel, magClones
end;
getMag = function(Key)
local model, clones = nil, nil
if magTable[Key] then
model, clones = magTable[Key][1], magTable[Key][2]
end
return model, clones
end;
attachGripToHead = function()
local handleCF = CharParts.RightArm.CFrame * Grip.C0
Grip.C0 = CF.OBJSPACE(CharParts.Head.CFrame,handleCF)
Grip.Part0 = CharParts.Head
end;
attachGripToArm = function()
local handleCF = CharParts.Head.CFrame * Grip.C0
Grip.C0 = CF.OBJSPACE(CharParts.RightArm.CFrame,handleCF)
Grip.Part0 = CharParts.RightArm
end;
Sine = Sine;
SineLit = Enum.EasingStyle.Sine;
LinearLit = Enum.EasingStyle.Linear;
Linear = Linear;
--VARIABLES--
Handle = Handle;
LArm = CharParts.LeftArm;
RArm = CharParts.RightArm;
LWeld = leftWeld;
RWeld = rightWeld;
LC0 = CF.RAW(-1.5, 0, 0);
RC0 = CF.RAW(1.5, 0, 0);
Grip = Grip;
gunIgnore = Character.MobParts;
CF = CF.RAW;
CFANG = CF.ANG;
V3 = V3;
RAD = RAD;
reloadTimeLoaded = settings.reloadSettings.Times.Loaded;
reloadTimeEmpty = settings.reloadSettings.Times.Empty
}
local sequenceTable = Anims.Reload(animVars)
--local T = tick()
for _, reloadFunction in pairs(sequenceTable) do
if breakReload then
break
end
reloadFunction()
if (not magVisible) then
Gun.Ammo.Value = 0
end
end
--print(tick() - T) --I divide the reloadTime by this number to get the animation speed
if (not isCrawling) then
if Running and (not settings.canFireWhileRunning) then
tween("Joint",leftWeld, CF.RAW(-1,0,0), settings.runningC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, CF.RAW(1,0,0), settings.runningC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.runningC1.Grip, Enum.EasingStyle.Sine, 0.4)
else
tween("Joint",leftWeld, nil, settings.unAimedC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, nil, settings.unAimedC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.unAimedC1.Grip, Enum.EasingStyle.Sine, 0.4)
end
end
tween("Recoil",V3(),V3(),Sine,0.2)
for _, v in pairs(magTable) do --In case the reload animations was stopped mid way and there were still fake mags that weren't deleted
v[1]:Destroy()
end
end
function animateCock()
-- tween("Joint",, CF.RAW(), CF.RAW(), Sine, 0.15)
-- tween("Joint",RWeld2, CF.RAW(), CF.RAW(), Sine, 0.15)
local magParts = {}
local magTable = {}
for i = 1,#Gun:GetChildren() do
if Gun:GetChildren()[i].Name:sub( 1, 3) == "Mag" and Gun:GetChildren()[i]:IsA("BasePart") then
INSERT(magParts, Gun:GetChildren()[i])
end
end
local animVars = {
--FUNCTIONS--
tweenJoint = function(Joint, newC0, newC1, Alpha, Duration)
tween("Joint",Joint,newC0,newC1,Alpha,Duration)
end;
tweenRecoil = function(Pos, Rot, Alpha, Duration)
tween("Recoil" , Pos, Rot, Alpha, Duration)
end;
makeMagInvisible = function()
for _, v in pairs(magParts) do
v.Transparency = 1
end
magVisible = false
end;
makeMagVisible = function()
for _, v in pairs(magParts) do
v.Transparency = v:WaitForChild("magTrans").Value
end
magVisible = true
end;
isMagVisible = function()
return magVisible
end;
isMagEmpty = function()
return ammoInClip == 0
end;
setNewMag = function()
newMag = true
end;
isNewMag = function()
return newMag
end;
getMag = function(Key)
local model, clones = nil, nil
if magTable[Key] then
model, clones = magTable[Key][1], magTable[Key][2]
end
return model, clones
end;
attachGripToHead = function()
local handleCF = Character:FindFirstChild("Right Arm").CFrame * Grip.C0
Grip.C0 = Character.Head.CFrame:toObjectSpace(handleCF)
Grip.Part0 = Character.Head
end;
attachGripToArm = function()
local handleCF = Character.Head.CFrame * Grip.C0
Grip.C0 = Character:FindFirstChild("Right Arm").CFrame:toObjectSpace(handleCF)
Grip.Part0 = Character:FindFirstChild("Right Arm")
end;
Sine = Sine;
Linear = Linear;
SineLit = Enum.EasingStyle.Sine;
LinearLit = Enum.EasingStyle.Linear;
--VARIABLES--
Handle = Handle;
LArm = Character:FindFirstChild("Left Arm");
RArm = Character:FindFirstChild("Right Arm");
LWeld = leftWeld;
RWeld = rightWeld;
LC0 = armC0[1];
RC0 = armC0[2];
Grip = Grip;
gunIgnore = Character.MobParts;
Cam = Character.MobCam;
CF = CF.RAW;
CFANG = CF.ANG;
V3 = V3;
RAD = RAD;
reloadTimeLoaded = settings.reloadSettings.Times.Loaded;
reloadTimeEmpty = settings.reloadSettings.Times.Empty
}
local sequenceTable = Anims.Cocking(animVars)
--local T = TICK()
for _, reloadFunction in pairs(sequenceTable) do
if breakReload then
break
end
reloadFunction()
if (not magVisible) then
Gun.Ammo.Value = 0
end
end
--print(TICK() - T) --I divide the reloadTime by this number to get the animation speed
if (not isCrawling) then
if Running and (not settings.canFireWhileRunning) then
tween("Joint",leftWeld, CF.RAW(-1,0,0), settings.runningC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, CF.RAW(1,0,0), settings.runningC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.runningC1.Grip, Enum.EasingStyle.Sine, 0.4)
else
tween("Joint",leftWeld, nil, settings.unAimedC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, nil, settings.unAimedC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.unAimedC1.Grip, Enum.EasingStyle.Sine, 0.4)
end
end
for _, v in pairs(magTable) do --In case the reload animations was stopped mid way and there were still fake mags that weren't deleted
v[1]:Destroy()
end
end
function Reload()
if Gun.Ammo.Value < (Gun.ClipSize.Value + 1) and (not Reloading) and Gun.StoredAmmo.Value > 0 then
ammoInClip = (ammoInClip == 0 and Gun.Ammo.Value or ammoInClip)
Reloading = true
lowerSpread()
if Aimed then
Aimed = false
Signals.AimChanged:fire(Aimed)
end
if Handle:FindFirstChild("ReloadSound") then Handle.ReloadSound:Play() end
if settings.reloadSettings.Anim then
wait()
animateReload()
else
local startReload = tick()
local initialReloadTime = Gun.Ammo.Value == 0 and settings.reloadSettings.Times.Empty or settings.reloadSettings.Times.Loaded
while true do
if breakReload then break end
if (tick() - startReload) >= initialReloadTime then break end
wait(1/60)
end
end
if (not breakReload) then
newMag = false
if Gun.StoredAmmo.Value >= Gun.ClipSize.Value then
if ammoInClip > 0 then
Gun.StoredAmmo.Value = Gun.StoredAmmo.Value - ((Gun.ClipSize.Value + 1) - ammoInClip)
Gun.Ammo.Value = Gun.ClipSize.Value + 1
else
Gun.StoredAmmo.Value = Gun.StoredAmmo.Value - Gun.ClipSize.Value
Gun.Ammo.Value = Gun.ClipSize.Value
end
elseif Gun.StoredAmmo.Value < Gun.ClipSize.Value and Gun.StoredAmmo.Value > 0 then
Gun.Ammo.Value = Gun.StoredAmmo.Value
Gun.StoredAmmo.Value = 0
end
end
Reloading = false
breakReload = false
end
end
function fire()
if Gun.Ammo.Value <= 0 then
shotCount = 0
lowerSpread()
return
end
local humanoidFound = false
local fireSound = Handle.Fire
if fireSound then
if settings.fireSoundSettings then
fireSound.TimePosition = settings.fireSoundSettings.Start
end
fireSound:Play()
end
for _ = 1, (settings.gunType.Shot and settings.shotAmount or 1) do
local randSpread1 = RAD(GunMath.RAND(0, 365))
local randSpread2 = RAD(GunMath.RAND(-(spreads.base + spreads.current), spreads.base + spreads.current, 0.01))
local spreadDir = CF.AA(V3(0, 0, 1), randSpread1) * CF.ANG(randSpread2, 0, 0)
local originCF = CF.AIMORIGIN(Aimed, settings,Flash)
local bulletDirection = CF.RAW(originCF.p, originCF.p + originCF.lookVector).lookVector
local Origin = Gun.Flash.CFrame.p
local bulletCF = CF.RAW(Origin, Origin + bulletDirection)
spawn(function()
Gun.Bolt.Transparency = 1
Gun.BoltBack.Transparency = 0
end)
if settings.bulletSettings.instantHit then
spawn(function()
local newRay
newRay = ((settings.sniperScope) and RAY.RAW(Character.Head.CFrame.p,bulletCF.lookVector) or RAY.RAW(Flash.CFrame.p, bulletDirection * settings.bulletSettings.Range))
if settings.sniperScope then
newRay = RAY.RAW(newRay.Origin,newRay.Direction * settings.bulletSettings.Range)
end
local H, P, N = RAY.CAST(WS,newRay, Ignore)
local finalP = P
if H then
-- if S.gunType.Explosive then
-- Libraries.Network.send("Server","FireExplosive_"..Player.UserId,gunIgnore,H,P,N,bulletDirection,Ignore)
-- else
_, finalP = penetrateWall(H, P, bulletDirection, N, {Character}, 0, (P - Flash.CFrame.p).magnitude, nil)
-- end
end
if settings.bulletTrail and settings.trailSettings.Transparency ~= 1 then
spawn(function()
local Trail = OBJ("Part")
Trail.BrickColor = settings.trailSettings.Color
Trail.Transparency = settings.trailSettings.Transparency
Trail.Anchored = true
Trail.CanCollide = false
Trail.Size = V3(1, 1, 1)
local Mesh = OBJ("CylinderMesh")
Mesh.Offset = V3(0, -((finalP or P) - Flash.CFrame.p).magnitude / 2, 0)
Mesh.Scale = V3(settings.trailSettings.Thickness, ((finalP or P) - Flash.CFrame.p).magnitude, settings.trailSettings.Thickness)
Mesh.Parent = Trail
Trail.Parent = Character.MobParts
Trail.CFrame = CF.RAW(Flash.CFrame.p, (finalP or P)) * CF.ANG(RAD(90),0,0)
delay(settings.trailSettings.visibleTime, function()
if settings.trailSettings.disappearTime > 0 then
local t0 = tick()
while true do
local Alpha = MIN((tick() - t0) / settings.trailSettings.disappearTime, 1)
Trail.Transparency = Lerp(settings.trailSettings.Transparency, 1, Alpha)
if Alpha == 1 then break end
wait(1/60)
end
end
Trail:Destroy()
end)
end)
end
end)
else
spawn(function()
local Bullet = createBullet(bulletDirection)
local debounce = true
Bullet.Touched:connect(function(part)
if part.Transparency == 1 then return end
if part:IsDescendantOf(Gun) then return end
if not part.Parent then return end
if debounce then
debounce = false
local newRay = RAY.RAW(Flash.CFrame.p, bulletDirection * settings.bulletSettings.Range)
local H, P, N = RAY.CAST(WS,newRay, Ignore)
if part.Name ~= "Bullet" and not part.Parent.Name:match("saber") then
if H ~= nil and not part.Name:find("Blade") then
penetrateWall(H, P, bulletDirection, N, {Character}, 0, (P - Gun.Flash.CFrame.p).magnitude, lDH)
elseif not part.Name:find("Blade") then
penetrateWall(part, P, bulletDirection, N, {Character}, 0, (P - Gun.Flash.CFrame.p).magnitude, lDH)
end
if Bullet.creator.Value ~= Character and part:IsDescendantOf(Character.GetTarget:Invoke().Parent) then
Damage(part, part.Position, N, Bullet.CFrame.lookVector, (P - Gun.Flash.CFrame.p).magnitude, {})
return
end
if lDH ~= nil then
Bullet:Destroy()
end
elseif part.Parent.Name:match("saber") then
Bullet.Velocity = -Bullet.Velocity
wait(1)
local list = {}
for _, part in pairs(CharParts) do
INSERT(list,part)
end
local part2 = list[RANDOM(#list)]
local chosenDamage = 0
if part2.Name == "Head" then
chosenDamage = RPGM.RangedCombatMath.HeadShotDamageAI(Gun.Damage.Value,Gun.HeadshotDamageMagnitude.Value)
elseif part2.Name == "Torso" then
chosenDamage = (RPGM.RangedCombatMath.TorsoDamageAI(Gun.Damage.Value,Bot,AttributeEffect,PerLevel))
else
chosenDamage = (RPGM.RangedCombatMath.RegularDamageAI(Gun.Damage.Value,Bot,AttributeEffect,PerLevel))
end
Humanoid:TakeDamage(chosenDamage)
Humanoid:TakeDamage(5)
end
---- if not isWallIgnored(part) then
---- MakeHole(part,P,N,humanoidFound)
---- end
if not part:IsDescendantOf(Character) and part.Name ~= "LZ" and not part.Name:find("Blade") then
Bullet:Destroy()
end
wait(0.75)
debounce = true
end
end)
end)
end
end
spreads.current = spreads.current + settings.spreadSettings.Increase
firstShot = Gun.Ammo.Value >= Gun.ClipSize.Value
local backRecoil = GunMath.RAND(settings.recoilSettings.Recoil.Back.Min, settings.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil
local upRecoil = GunMath.RAND(settings.recoilSettings.Recoil.Up.Min, settings.recoilSettings.Recoil.Up.Max, 0.01) --Get the up recoil
local sideRecoilAlpha = 0
if lastSideRecoil[1] < 0 and lastSideRecoil[2] < 0 then --This conditional basically makes sure the gun tilt isn't in the same direction for more than 2 shots
sideRecoilAlpha = GunMath.RAND(0, 1, 0.1)
elseif lastSideRecoil[1] > 0 and lastSideRecoil[2] > 0 then
sideRecoilAlpha = GunMath.RAND(-1, 0, 0.1)
else
sideRecoilAlpha = GunMath.RAND(-1, 1, 0.1)
end
local sideRecoil = Lerp(settings.recoilSettings.Recoil.Side.Left, settings.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil
local tiltRecoil = Lerp(settings.recoilSettings.Recoil.Tilt.Left, settings.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil
local recoilPos = V3(
0,---sideRecoil,
0,
-backRecoil
) * (Aimed and settings.recoilSettings.aimedMultiplier or 1)
local recoilRot = V3(
(Aimed and 0 or (-RAD(upRecoil * 10) * (firstShot and settings.recoilSettings.firstShotMultiplier or 1))),
RAD(sideRecoil * 10),
RAD(tiltRecoil * 10)
) * (Aimed and settings.recoilSettings.aimedMultiplier or 1)
local camRecoilRot = V3(
-RAD(sideRecoil * 10),
RAD(upRecoil * 10) * (firstShot and settings.recoilSettings.firstShotMultiplier or 1) * settings.recoilSettings.camMultiplier,
0
) * (Aimed and settings.recoilSettings.aimedMultiplier or 1) * stanceSway
tween("Recoil",recoilPos, recoilRot, Sine, 0.2)
tween("Cam","Recoil", camRecoilRot, Sine, 0.15 * (firstShot and settings.recoilSettings.firstShotMultiplier or 1))
spawn(function()
for i = 1,#Flash:GetChildren() do
local MainItem = Flash:GetChildren()[i]
if MainItem.Name:sub(1, 7) == "FlashFX" then
MainItem.Enabled = true
end
end
end)
delay(1 * 0.05, function()
tween("Recoil",V3(), V3(), Sine, 0.2)
tween("Cam","Recoil", V3(), Sine, 0.2)
for i = 1,#Flash:GetChildren() do
local MainItem = Flash:GetChildren()[i]
if MainItem.Name:sub(1, 7) == "FlashFX" then
MainItem.Enabled = false
end
end
end)
Gun.Bolt.Transparency = 0
Gun.BoltBack.Transparency = 1
if settings.cockingAnim then
repeat RS.Heartbeat:wait() until not Aimed
animateCock()
end
firstShot = false
shotCount = shotCount + 1
lastSideRecoil[(shotCount % 2) + 1] = sideRecoilAlpha
end
function onActivated()
if Gun.Ammo.Value > 0 then
Gun.Ammo.Value = Gun.Ammo.Value - 1
newMag = false
fire()
end
if settings.reloadSettings.magIsBullet then
for _, Mag in pairs(Gun:GetChildren()) do
if Mag.Name:sub(1, 3) == "Mag" then
Mag.Transparency = 1
end
end
end
end
function createBullet(bulletDirection)
local Origin = Gun.Flash.CFrame.p
local Bullet
local bulletCF = CF.RAW(Origin, Origin + bulletDirection)
Bullet = Instance.new("Part")
Bullet.BrickColor = settings.bulletSettings.Color;
Bullet.Material = Enum.Material.Neon
Bullet.Name = "Bullet"
Bullet.CanCollide = false
Bullet.FormFactor = "Custom"
Bullet.Size = settings.bulletSettings.Size
Bullet.BottomSurface = "Smooth"
Bullet.TopSurface = "Smooth"
local BF = Instance.new("BodyForce")
BF.force = V3(0, Bullet:GetMass() * (196.2 - 0.2), 0)
BF.Parent = Bullet
Bullet.Velocity = bulletDirection * settings.bulletSettings.Velocity
Bullet.Parent = workspace.BulletStorage:FindFirstChild(Bot.Allegiance)
Bullet.CFrame = bulletCF + bulletDirection * settings.bulletSettings.Size.Z / 2
local BulletMark = OBJ("ObjectValue")
BulletMark.Name = "creator"
BulletMark.Value = Character
BulletMark.Parent = Bullet
delay(10, function()
Bullet:Destroy()
end)
return Bullet
end
function createGrenadeCore(Grenade)
local Center = Instance.new("Part")
Center.BrickColor = settings.grenadeSettings.Lethal.color
Center.Name = "Center"
Center.CanCollide = false
Center.Elasticity = 0
Center.Material = settings.grenadeSettings.Lethal.material
Center.FormFactor = Enum.FormFactor.Custom
Center.Size = settings.grenadeSettings.Size
Center.BottomSurface = Enum.SurfaceType.Smooth
Center.TopSurface = Enum.SurfaceType.Smooth
Center.Parent = Grenade
local Mesh1 = Instance.new("FileMesh")
Mesh1.MeshId = "rbxassetid://431532852"
Mesh1.TextureId = "rbxassetid://431532899"
Mesh1.Scale = V3(0.002, 0.002, 0.002)
Mesh1.Parent = Center
end
--------------------[ GRENADE FUNCTIONS ]---------------------------------------------
--Grenade and knifing functions integration credit to Alpha and Aerodos12.
local GrenadeAppearanceType = 2
function CreateGrenade(Type)
local Grenade
if GrenadeAppearanceType == 1 then
Grenade = Instance.new("Model")
createGrenadeCore(Grenade)
else
if Type == 1 then
if settings.grenadeSettings.Lethal.Type == 1 then
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Frag"):Clone()
elseif settings.grenadeSettings.Lethal.Type == 4 then
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Molotov"):Clone()
elseif settings.grenadeSettings.Lethal.Type == 2 then
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Sticky"):Clone()
end
elseif Type == 2 then
if settings.grenadeSettings.Tactical.Type == 1 then
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Smoke"):Clone()
elseif settings.grenadeSettings.Tactical.Type == 2 then
Grenade = game.ReplicatedStorage.Grenades:FindFirstChild("Flashbang"):Clone()
end
end
end
return Grenade
end
function CreateKnife()
local Knife = Instance.new("Part")
--Knife.BrickColor = S.TacticalGrenadeColor
Knife.Name = "Knife"
Knife.CanCollide = false
Knife.FormFactor = Enum.FormFactor.Custom
Knife.Size = V3(1, 1, 3)
local Mesh = Instance.new("SpecialMesh")
Mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
Mesh.MeshType = Enum.MeshType.FileMesh
Mesh.Scale = V3(0.5, 0.5, 0.5)
Mesh.Parent = Knife
return Knife
end
function ThrowGrenade(Type)
if isCrawling then return end
local grenadeTable = {}
local animVars = {
tweenJoint = function(Joint, C0, C1, Alpha, Duration)
tween("Joint",Joint, C0, C1, Alpha, Duration)
end;
detachAndResetGrip = function()
Grip.Part0 = CharParts.RightArm
Grip.C1 = CF.ANG(0, RAD(20), 0)
end;
attachGripToTorso = function()
Grip.Part0 = CharParts.Torso
Grip.C1 = CF.RAW(-1, 0.5, -0.5)
end;
createGrenade = function(Name,Type,weldNade,tickOn)
local nade
if settings.LethalGrenadeType == 3 and Type == 1 then
nade = CreateKnife()
nade.Parent = workspace.GrenadeStorage
if weldNade then
local Weld = Instance.new("Motor6D")
Weld.Part0 = CharParts.RightArm
Weld.Part1 = nade
Weld.C0 = Grip.C0
Weld.C1 = CF.RAW(0, 0, -0.5) * CF.ANG(RAD(90), RAD(90), 0)
Weld.Parent = nade
end
else
nade = CreateGrenade(Type)
nade.Parent = workspace.GrenadeStorage
if weldNade then
local Weld = Instance.new("Motor6D")
Weld.Part0 = CharParts.RightArm
Weld.Part1 = nade:WaitForChild("Center")
Weld.C0 = Grip.C0
Weld.Parent = nade:WaitForChild("Center")
end
end
if nade then
if tickOn then
nade.Tick.Disabled = false
end
end
grenadeTable[Name] = nade
return nade, Name
end;
destroyNade = function(key)
grenadeTable[key]:Destroy()
grenadeTable[key] = nil
end;
getNade = function(key)
return grenadeTable[key], key
end;
setNadeCFrame = function(key, nadeCF)
local nade = ((grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.CFrame = nadeCF
end;
addNadeVelocity = function(key, vel)
local nade = ((grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.Velocity = nade.Velocity + vel
end;
divideNadeVelocity = function(key, vel)
local nade = ((grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.Velocity = nade.Velocity / vel
end;
setNadeRotVelocity = function(key, vel)
local nade = ((grenadeTable[key]:IsA("BasePart")) and grenadeTable[key] or grenadeTable[key]:WaitForChild("Center",200))
nade.RotVelocity = vel
end;
mainCF = function(Main)
return Main.Center.CFrame
end;
headCF = function()
return CharParts.Head.CFrame
end;
playSound = function(sound,Parent)
local Sound = Instance.new("Sound")
Sound.SoundId = sound
Sound.Volume = 1
Sound.Parent = Parent
end;
nadeIsA = function(nadeType)
local nadetypes = {
[1] = {
["Frag"] = 1;
["Sticky"] = 2;
["ThrowingKnife"] = 3;
["Molotov"] = 4;
};
[2] = {
["Smoke"] = 1;
["Flashbang"] = 2;
};
}
local returnType
if Type == 1 then
returnType = settings.grenadeSettings.Lethal.Type;
elseif Type == 2 then
returnType = settings.grenadeSettings.Tactical.Type;
end
return nadetypes[Type][nadeType] == returnType;
end;
Detonate = function(bt,...)
Detonator:RunBehavior(bt,...)
end;
isIgnored = function(Obj)
return isIgnored(Obj, Ignore)
end;
stick = function(gCF,key,Obj)
local W = Instance.new("Motor6D")
W.Name = "Semtex"
W.Part0 = grenadeTable[key]:WaitForChild("Center",200)
W.Part1 = Obj
W.C0 = gCF:toObjectSpace(Obj.CFrame)
W.Parent = grenadeTable[key]
grenadeTable[key].ChildRemoved:connect(function(C)
if C.Name == "Semtex" then
local W = Instance.new("Motor6D")
W.Name = "Semtex"
W.Part0 = grenadeTable[key]:WaitForChild("Center",200)
W.Part1 = Obj
W.C0 = gCF:toObjectSpace(Obj.CFrame)
W.Parent = grenadeTable[key]
end
end)
end;
LWeld = leftWeld;
RWeld = rightWeld;
CF = CF.RAW;
CFANG = CF.ANG;
Grip = Grip;
RAD = RAD;
Linear = Linear;
Sine = Sine;
SineLit = Enum.EasingStyle.Sine;
LinearLit = Enum.EasingStyle.Linear;
Type = Type;
lNadeType = settings.grenadeSettings.Lethal.Type;
throwVelocity = settings.grenadeSettings.Lethal.throwVelocity;
throwVelocityTactical = settings.grenadeSettings.Tactical.throwVelocity;
LWeld2 = LWeld2;
RWeld2 = RWeld2;
LC0 = armC0[1];
RC0 = armC0[2];
FRArm = CharParts.RightArm;
FLArm = CharParts.LeftArm;
timerStartOnHit = settings.grenadeSettings.detonationSettings.StartOnHit;
detonationTime = settings.grenadeSettings.detonationSettings.Time;
lethalGrenadeDamage = settings.grenadeSettings.Lethal.damage;
allowFriendlyFire = settings.AllowFriendlyFire;
CanDamageNPCs = settings.CanDamageNPCs;
ShockwaveColor = settings.shockwaveSettings.Color;
explosionType = settings.grenadeSettings.Type;
blastRadius = settings.grenadeSettings.Radius;
blastPressure = settings.grenadeSettings.Pressure;
ShockwaveDuration = settings.shockwaveSettings.Duration;
grenadeEffectRadius = settings.grenadeSettings.detonationSettings.effectRadius;
grenadeEffectTime = settings.grenadeSettings.detonationSettings.effectTime;
ignoreCode = 0;
}
local AnimTable = Anims.Nading(animVars)
for _,F in pairs(AnimTable) do
F()
end
tween("Joint", leftWeld, armC0[1], settings.unAimedC1.leftArm, Enum.EasingStyle.Linear, 0.2)
tween("Joint", rightWeld, armC0[2], settings.unAimedC1.rightArm, Enum.EasingStyle.Linear, 0.2)
end
Gun.throwGrenade.Event:connect(function(gType)
ThrowGrenade(gType)
end)
local function getAnimCF()
return CF.RAW(aimHeadOffset, 0, 0) * CF.ANG(
(RecoilSpring.p.X + BasePose.Rot.X) * stanceSway,
(RecoilSpring.p.Y + BasePose.Rot.Y) * stanceSway,
(RAD(armTilt) * armTiltMultiplier + RecoilSpring.p.Z + BasePose.Rot.Z) * stanceSway
) * CF.RAW(
(BasePose.Pos.X + Recoil.Pos.X) * stanceSway,
(BasePose.Pos.Y + BasePose.Pos.Y) * stanceSway,
(BasePose.Pos.Z + Recoil.Pos.Z) * stanceSway
), CF.ANG(-camAng.Y * crawlAlpha / 90, 0, 0) * CF.RAW(aimHeadOffset, -1, 0)
end
function canRun(midRun)
return (Humanoid.WalkSpeed >= 25) and (Stamina > 0) and Running and (midRun and true or onGround) and
runReady and (settings.canFireWhileRunning and true or (not Firing))
end
function monitorStamina()
Running = true
if (not canRun(false)) then
Running = false
return
end
if Aimed then
Aimed = false
Signals.AimChanged:fire(Aimed)
end
if (not (Reloading and settings.reloadSettings.Anim)) then
if settings.canFireWhileRunning then
tween("Joint",leftWeld, nil, settings.unAimedC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, nil, settings.unAimedC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.unAimedC1.Grip, Enum.EasingStyle.Sine, 0.4)
else
tween("Joint",leftWeld, nil, settings.runningC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, nil, settings.runningC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.runningC1.Grip, Enum.EasingStyle.Sine, 0.4)
end
end
while runKeyPressed and canRun(true) do
if onGround then
local newStamina = Stamina - 1
Stamina = (newStamina < 0 and 0 or newStamina)
end
wait(1/60)
end
Running = false
if (not Aimed) and (not (Reloading and settings.reloadSettings.Anim)) and (not settings.canFireWhileRunning) then
tween("Joint",leftWeld, nil, settings.unAimedC1.leftArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",rightWeld, nil, settings.unAimedC1.rightArm, Enum.EasingStyle.Sine, 0.4)
tween("Joint",Grip, nil, settings.unAimedC1.Grip, Enum.EasingStyle.Sine, 0.4)
end
rechargeStamina()
end
function rechargeStamina()
chargingStamina = true
while ((not runKeyPressed) or (Stamina < maxStamina)) and (not Running) do
local newStamina = Stamina + (settings.sprintTime / settings.staminaCoolTime)
Stamina = (newStamina > maxStamina and maxStamina or newStamina)
wait(1/60)
end
chargingStamina = false
end
StanceFunctions["Stand"] = function()
CharJoints.LeftHip.Part1 = CharParts.LeftLeg
leftCrouchWeld.Part1 = nil
CharJoints.RightHip.Part1 = CharParts.RightLeg
rightCrouchWeld.Part1 = nil
Stance = 0
spreadStance = "Stand"
spreads.base = settings.spreadSettings[spreadZoom][spreadStance][spreadMotion]
spawn(function()
local prevStanceSway = stanceSway
local X = 0
local Increment = 1.5 / settings.stanceSettings.Speed
while X < 90 do
wait(1/60)
X = X + Increment
if Stance ~= 0 then break end
stanceSway = Lerp(prevStanceSway, 1, Sine(X))
end
end)
tween("Joint",ABWeld, CF.RAW(), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",leftCrouchWeld, legC0.Stand[1], nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",rightCrouchWeld, legC0.Stand[2], nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.LeftHip, CF.RAW(-1, -1, 0) * CF.ANG(0, RAD(-90), 0), CF.RAW(-0.5, 1, 0) * CF.ANG(0, RAD(-90), 0), Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.RightHip, CF.RAW(1, -1, 0) * CF.ANG(RAD(-180), RAD(90), 0), CF.RAW(0.5, 1, 0) * CF.ANG(RAD(-180), RAD(90), 0), Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.Root, CF.ANG(RAD(-90), 0, RAD(180)), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",headWeld, CF.RAW(0, 1.5, 0), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
end
StanceFunctions["Crouch"] = function()
CharJoints.LeftHip.Part1 = nil
leftCrouchWeld.Part1 = CharParts.LeftLeg
CharJoints.RightHip.Part1 = nil
rightCrouchWeld.Part1 = CharParts.RightLeg
Stance = 1
spreadStance = "Crouch"
spreads.base = settings.spreadSettings[spreadZoom][spreadStance][spreadMotion]
spawn(function()
local prevStanceSway = stanceSway
local X = 0
local Increment = 1.5 / settings.stanceSettings.Speed
while X < 90 do
wait(1/60)
X = X + Increment
if Stance ~= 1 then break end
stanceSway = Lerp(prevStanceSway, 0.75, Sine(X))
end
end)
tween("Joint",ABWeld, CF.RAW(0, 0, -0.05), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",leftCrouchWeld, legC0.Crouch[1], nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",rightCrouchWeld, legC0.Crouch[2], nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.LeftHip, CF.RAW(-1, -0.5, 0) * CF.ANG(0, RAD(-90), 0), CF.RAW(-0.5, 0.5, 1) * CF.ANG(0, RAD(-90), RAD(-90)), Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.RightHip, CF.RAW(1, -0.5, 0.25) * CF.ANG(RAD(-180), RAD(90), 0), CF.RAW(0.5, 0.5, 1) * CF.ANG(RAD(-180), RAD(90), 0), Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.Root, CF.RAW(0, -1, 0) * CF.ANG(RAD(-90), 0, RAD(180)), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",headWeld, CF.RAW(0, 1.5, 0), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
end;
StanceFunctions["Prone"] = function()
Stance = 2
spreadStance = "Prone"
spreads.base = settings.spreadSettings[spreadZoom][spreadStance][spreadMotion]
spawn(function()
local prevStanceSway = stanceSway
local X = 0
local Increment = 1.5 / settings.stanceSettings.Speed
while X < 90 do
wait(1/60)
X = X + Increment
if Stance ~= 2 then break end
stanceSway = Lerp(prevStanceSway, 0.5, Sine(X))
end
end)
tween("Joint",ABWeld, CF.RAW(0, 0, -0.1), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",leftCrouchWeld, legC0.Prone[1], nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",rightCrouchWeld, legC0.Prone[2], nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",CharJoints.Root, CF.RAW(0, -2.5, 1) * CF.ANG(RAD(180), 0, RAD(180)), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
tween("Joint",headWeld, CF.RAW(0, 1, 1) * CF.ANG(RAD(90), 0, 0), nil, Enum.EasingStyle.Sine, settings.stanceSettings.Speed)
end
StanceFunctions["Normal"] = function(...)
tween("Joint",leftWeld,nil,settings.unAimedC1.leftArm,Enum.EasingStyle.Sine,0.4)
tween("Joint",rightWeld,nil,settings.unAimedC1.rightArm,Enum.EasingStyle.Sine,0.4)
tween("Joint",Grip,nil,settings.unAimedC1.Grip,Enum.EasingStyle.Sine,0.4)
Humanoid.WalkSpeed = 16
end
function RecalibrateOwner()
Character = Gun.Parent
Bot = require(Character.BOT)
CharParts = {
Head = Character:WaitForChild("Head",200),
LeftLeg = Character:WaitForChild("Left Leg",200),
RightLeg = Character:WaitForChild("Right Leg",200),
Torso = Character:WaitForChild("Torso",200),
RightArm = Character:WaitForChild("Right Arm",200),
LeftArm = Character:WaitForChild("Left Arm",200),
HRP = Character:WaitForChild("HumanoidRootPart",200)
}
CharJoints = {
Root = CharParts.HRP:WaitForChild("RootJoint",200);
LeftHip = CharParts.Torso:WaitForChild("Left Hip",200);
RightHip = CharParts.Torso:WaitForChild("Right Hip",200);
LeftShoulder = CharParts.Torso:FindFirstChild("Left Shoulder");
RightShoulder = CharParts.Torso:FindFirstChild("Right Shoulder");
}
Humanoid = Character.Human
end
function getAimedGripCF(Grip)
local handleCF = CharParts.Torso.CFrame * CF.RAW(0, 0.5, 0) * armC0[2] * settings.aimedC1.rightArm:inverse() * Grip.C0
local handleOffset = CF.OBJSPACE(Gun.AimPart.CFrame,Handle.CFrame)
local aimedGripCF = CF.OBJSPACE((((CharParts.Torso.CFrame * CF.RAW(headOffset.X, headOffset.Y, 0)) * handleOffset)),handleCF)
return aimedGripCF
end
local function clamp(low, high, num)
return (num > high and high or num < low and low or num)
end
function CreateParts()
headBase = Instance.new("Part")
headBase.Transparency = 1
headBase.Name = "headBase"
headBase.CanCollide = false
headBase.FormFactor = Enum.FormFactor.Custom
headBase.Size = V3(0.2, 0.2, 0.2)
headBase.BottomSurface = Enum.SurfaceType.Smooth
headBase.TopSurface = Enum.SurfaceType.Smooth
headBase.Parent = MobFolder
headBase:SetNetworkOwner(nil)
headWeld = OBJ("Motor6D")
headWeld.Part0 = CharParts.Torso
headWeld.Part1 = headBase
headWeld.C0 = CF.RAW(0, 1.5, 0)
headWeld.Parent = CharParts.Torso
headWeld2 = OBJ("Weld")
headWeld2.Part0 = headBase
headWeld2.Part1 = CharParts.Head
headWeld2.Parent = headBase
local animBase = Instance.new("Part")
animBase.Transparency = 1
animBase.Name = "animBase"
animBase.CanCollide = false
animBase.FormFactor = Enum.FormFactor.Custom
animBase.Size = V3(0.2, 0.2, 0.2)
animBase.BottomSurface = Enum.SurfaceType.Smooth
animBase.TopSurface = Enum.SurfaceType.Smooth
animBase.Parent = MobFolder
animBase:SetNetworkOwner(nil)
animWeld = OBJ("Motor6D")
animWeld.Part0 = animBase
animWeld.Part1 = headBase
animWeld.Parent = animBase
local ArmBase = OBJ("Part")
ArmBase.Size = V3(0.2,.2,.2)
-- ArmBase:ClearAllChildren()
ArmBase.Name = "ArmBase"
ArmBase.CanCollide = false
ArmBase.Transparency = 1
ArmBase.Parent = MobFolder
ABWeld = OBJ("Motor6D")
ABWeld.Part0 = ArmBase
ABWeld.Part1 = animBase
ABWeld.Parent = ArmBase
local LArmBase = Instance.new("Part")
LArmBase.Transparency = 1
LArmBase.Name = "LArmBase"
LArmBase.CanCollide = false
LArmBase.FormFactor = Enum.FormFactor.Custom
LArmBase.Size = V3(0.2, 0.2, 0.2)
LArmBase.BottomSurface = Enum.SurfaceType.Smooth
LArmBase.TopSurface = Enum.SurfaceType.Smooth
LArmBase.Parent = MobFolder
LArmBase:SetNetworkOwner(nil)
local RArmBase = Instance.new("Part")
RArmBase.Transparency = 1
RArmBase.Name = "RArmBase"
RArmBase.CanCollide = false
RArmBase.FormFactor = Enum.FormFactor.Custom
RArmBase.Size = V3(0.2, 0.2, 0.2)
RArmBase.BottomSurface = Enum.SurfaceType.Smooth
RArmBase.TopSurface = Enum.SurfaceType.Smooth
RArmBase.Parent = MobFolder
RArmBase:SetNetworkOwner(nil)
leftWeld = OBJ("Motor6D")
leftWeld.Name = "LWeld"
leftWeld.Part0 = ArmBase
leftWeld.Part1 = LArmBase
leftWeld.C0 = armC0[1]
leftWeld.C1 = settings.equipSettings.leftArmC1
leftWeld.Parent = ArmBase
rightWeld = OBJ("Motor6D")
rightWeld.Name = "RWeld"
rightWeld.Part0 = ArmBase
rightWeld.Part1 = RArmBase
rightWeld.C0 = armC0[2]
rightWeld.C1 = settings.equipSettings.rightArmC1
rightWeld.Parent = ArmBase
LWeld2 = OBJ("Motor6D")
LWeld2.Name = "LWeld"
LWeld2.Part0 = LArmBase
LWeld2.Part1 = CharParts.LeftArm
LWeld2.Parent = LArmBase
RWeld2 = OBJ("Motor6D")
RWeld2.Name = "RWeld"
RWeld2.Part0 = RArmBase
RWeld2.Part1 = CharParts.RightArm
RWeld2.Parent = RArmBase
leftCrouchWeld = OBJ("Motor6D")
leftCrouchWeld.Name = "LLegWeld"
leftCrouchWeld.Part0 = CharParts.Torso
leftCrouchWeld.Part1 = nil
leftCrouchWeld.C0 = leftCrouchWeld.C0 * CF.RAW(-0.5, -2, 0)
leftCrouchWeld.Parent = CharParts.Torso
rightCrouchWeld = OBJ("Motor6D")
rightCrouchWeld.Name = "RLegWeld"
rightCrouchWeld.Part0 = CharParts.Torso
rightCrouchWeld.Part1 = nil
rightCrouchWeld.C0 = rightCrouchWeld.C0 * CF.RAW(0.5, -2, 0)
rightCrouchWeld.Parent = CharParts.Torso
end
Gun.GetAim.OnInvoke = function()
return Aimed
end
local SpeedRatio = settings.walkSpeeds.Aimed / settings.walkSpeeds.Base
local function isCrawling()
return (Stance == 2 and onGround and settings.stanceSettings.crawlAnimation) and ((Speed >= (Aimed and (settings.walkSpeeds.Prone * SpeedRatio) or settings.walkSpeeds.Prone)))
end
local function isRunning()
return Speed >= settings.walkSpeeds.Sprinting and ((not settings.stopAnimsOnFall) and true or onGround) and not isCrawling
end
local function isIdling()
return ((not onGround) and settings.stopAnimsOnFall) and true or ((Speed <= 0)) and (not isCrawling)
end
local function isWalking()
return ((Speed >= (Aimed and (settings.walkSpeeds.Base * SpeedRatio) or settings.walkSpeeds.Base) and Speed < settings.walkSpeeds.Sprinting) and ((not settings.stopAnimsOnFall) and true or onGround)) and not Running and not isCrawling
end
Gun.Equip.Event:connect(function()
RecalibrateOwner()
local SpreadSettings = settings.spreadSettings
--Humanoid.AutoRotate = false
CharJoints.LeftShoulder.Part1, CharJoints.RightShoulder.Part1 = nil, nil
CharJoints.LeftShoulder.Part0, CharJoints.RightShoulder.Part0 = nil, nil
-- for _, Tab in PAIRS(gunParts) do
-- local Weld = OBJ("Weld")
-- Weld.Name = "MainWeld"
-- Weld.Part0 = Handle
-- Weld.Part1 = Tab.Obj
-- Weld.C0 = Tab.Obj.weldCF.Value
-- Weld.Parent = Handle
-- Tab.Weld = Weld
-- end
MobFolder = OBJ("Folder")
MobFolder.Name = "MobParts"
MobFolder.Parent = Character
CreateParts()
CharParts.LeftArm.CanCollide = false
CharParts.RightArm.CanCollide = false
Grip = Instance.new("Motor6D")
Grip.Name = "RightGrip"
Grip.Part0 = CharParts.RightArm
Grip.Part1 = Handle
Grip.C0 = CF.RAW(0, -1, 0) * CF.ANG(-0.5 * math.pi, 0, 0)
Grip.C1 = settings.equipSettings.GripC1
Grip.Parent = CharParts.RightArm
StanceFunctions["Normal"]()
local walkingForward,walkingBackward,walkingLeft,walkingRight
local initialX, initialY = getYawPitch(Character.Head.CFrame)
camAng = -VEC2(initialX, initialY)
local aimedGripCF = getAimedGripCF(Grip)
Equipped = true
INSERT(Connections, Humanoid.Jumping:connect(function()
if Stance ~= 0 then
StanceFunctions["Stand"]()
end
end))
INSERT(Connections,Gun.Running.Changed:connect(function(running)
runKeyPressed = running
if runKeyPressed then
monitorStamina()
end
end))
INSERT(Connections, Gun.TargetCFrame.Changed:connect(function(cf)
renderCamera()
local AngX,AngY = getYawPitch(Character.MobCam.CFrame)
camAng = VEC2(-AngX, clamp(AngY,RAD(90),RAD(-90)))
local cX,cY = CF.RAW(Character.PrimaryPart.CFrame.p) * CF.ANG(0,camAng.X,0),CF.ANG(camAng.Y,0,0)
headWeld.C1 = cY
if (not Humanoid.Sit and not Humanoid.PlatformStand) then
Character.PrimaryPart.CFrame = cX
end
end))
INSERT(Connections,Humanoid.Running:connect(function(speed)
local _, dt = wait(1/60)
Speed = speed
Gun.Running.Value = (speed >= 25)
crawlAlpha = clamp(crawlAlpha + (isCrawling() and Increment or -Increment) * dt, 90, 0)
idleAlpha = clamp(idleAlpha + (isIdling() and Increment or -Increment) * dt, 90, 0)
walkAlpha = clamp(walkAlpha + (isWalking() and Increment or -Increment) * dt, 90, 0)
runAlpha = clamp(runAlpha + (isRunning() and Increment or -Increment) * dt, 90, 0)
spreadMotion = (((isWalking() or isRunning()) and not Aimed) and "Moving" or "Idling")
spreads.base = SpreadSettings[spreadZoom][spreadStance][spreadMotion]
local Velocity = CharParts.Torso.Velocity
walkingForward = ((Humanoid.MoveDirection.Z == -1) or ((Velocity.Z <= -1) and (Speed >= settings.walkSpeeds.Base)))
walkingBackward = ((Humanoid.MoveDirection.Z == 1) or ((Velocity.Z >= 1) and (Speed >= settings.walkSpeeds.Base)))
walkingLeft = ((Humanoid.MoveDirection.X == -1) or ((Velocity.X <= -1) and (Speed >= settings.walkSpeeds.Base)))
walkingRight = ((Humanoid.MoveDirection.X == 1) or ((Velocity.X >= 1) and (Speed >= settings.walkSpeeds.Base)))
local newArmTilt = (
((walkingForward or walkingBackward) and walkingRight) and 2.5 or
((walkingForward or walkingBackward) and walkingLeft) and -2.5 or
(((not (walkingForward and walkingBackward))) and walkingRight) and 5 or
(((not (walkingForward and walkingBackward))) and walkingLeft) and -5 or 0
)
print("Arm Tilt:", newArmTilt)
local startTilt = armTilt
local Increment = (startTilt == newArmTilt and 1.5 / 0.7 or 1.5 / (0.35 * ABS(startTilt - newArmTilt) * 0.2))
spawn(function()
local X = 0
while X < 90 and Character.Torso.Velocity.magnitude > 0 do
RS.Heartbeat:wait()
X = X + Increment
armTilt = Lerp(startTilt,newArmTilt,SIN(RAD(X)))
end
end)
end))
INSERT(Connections,RS.Heartbeat:connect(function(dt)
local posHip, rotHip, posAim, rotAim =
(
Sine(idleAlpha) * (Anims.Idling["unAimed"](BasePose.Ang)).Pos
) + (
Sine(walkAlpha) * (Anims.Walking["unAimed"](BasePose.Ang)).Pos
) + (
Sine(runAlpha) * (Anims.Running(BasePose.Ang)).Pos
),
(
Sine(idleAlpha) * (Anims.Idling["unAimed"](BasePose.Ang)).Rot
) + (
Sine(walkAlpha) * (Anims.Walking["unAimed"](BasePose.Ang)).Rot
) + (
Sine(runAlpha) * (Anims.Running(BasePose.Ang)).Rot
),
(
Sine(idleAlpha) * (Anims.Idling["Aimed"](BasePose.Ang)).Pos
) + (
Sine(walkAlpha) * (Anims.Walking["Aimed"](BasePose.Ang)).Pos
) + (
Sine(runAlpha) * (Anims.Running(BasePose.Ang)).Pos
),
(
Sine(idleAlpha) * (Anims.Idling["Aimed"](BasePose.Ang)).Rot
) + (
Sine(walkAlpha) * (Anims.Walking["Aimed"](BasePose.Ang)).Rot
) + (
Sine(runAlpha) * (Anims.Running(BasePose.Ang)).Rot
)
BasePose.Pos = (1 - aimAlpha) * posHip + aimAlpha * posAim
BasePose.Rot = (1 - aimAlpha) * rotHip + aimAlpha * rotAim
BasePose.Ang = BasePose.Ang + RAD(105 * dt) * stanceSway
local animC0,animC1 = getAnimCF()
animWeld.C0 = animC0
animWeld.C1 = animC1
if Running then
Aimed = false
Signals.AimChanged:fire(Aimed)
end
end))
INSERT(Connections,Gun.Ammo.Changed:connect(function(ammo)
if ammo == 0 and settings.reloadSettings.autoReload then
wait(0.2)
Reload()
end
end))
INSERT(Connections, Gun.SetAimed.Event:connect(function(aimed)
Aimed = (aimed)
Signals.AimChanged:fire(Aimed)
end))
INSERT(Connections,Gun.ChangeStance.Event:connect(function(...)
local args = {...}
local stance = args[1]
StanceFunctions[stance]()
end))
INSERT(Connections,Signals.AimChanged:connect(function(aimed)
Humanoid.WalkSpeed = (aimed and settings.walkSpeeds.Aimed or settings.walkSpeeds.Base)
spreadZoom = (aimed and "Aimed" or "unAimed")
spreads.base = settings.spreadSettings[spreadZoom][spreadStance][spreadMotion]
tween("Joint",leftWeld, nil, (aimed and settings.aimedC1.leftArm or settings.unAimedC1.leftArm), Enum.EasingStyle.Sine, settings.aimSettings.Speed)
tween("Joint",rightWeld, nil, (aimed and settings.aimedC1.rightArm or settings.unAimedC1.rightArm), Enum.EasingStyle.Sine, settings.aimSettings.Speed)
tween("Joint",Grip, nil, (aimed and aimedGripCF or settings.unAimedC1.Grip), Enum.EasingStyle.Sine, settings.aimSettings.Speed)
tween("Joint",headWeld2, nil, (aimed and CF.RAW(0, -0.5, 0) * CF.ANG(0, 0, settings.aimSettings.headTilt) * CF.RAW(0, 0.5, 0) or CF.RAW()), Enum.EasingStyle.Sine, settings.aimSettings.Speed)
tween("Aim",settings.aimSettings.Speed,Sine,aimed)
end))
end)
function unEquip(death,destroy)
Equipped = false
StanceFunctions["Normal"]()
headWeld:Destroy()
headWeld2:Destroy()
headBase:Destroy()
MobFolder:Destroy()
if not death then
CharParts.LeftArm.CanCollide = true
CharParts.RightArm.CanCollide = true
StanceFunctions["Stand"]()
CharJoints.LeftShoulder.Part1, CharJoints.RightShoulder.Part1 = CharParts.LeftArm, CharParts.RightArm
CharJoints.LeftShoulder.Part0, CharJoints.RightShoulder.Part0 = CharParts.Torso, CharParts.Torso
Grip:Destroy()
end
for _, c in pairs(Connections) do
c:disconnect()
end
Connections = {}
if destroy then
Gun:Destroy()
end
end
INSERT(Connections,Humanoid.Died:connect(function()
unEquip(true)
end))
Gun.Unequip.Event:connect(unEquip)
Gun.Activate.Event:connect(onActivated)
local LoadoutPackage = {}
local LoadoutClass = require(script.Parent.LoadoutClass)
local Slot = require(script.Parent.PackageSlot)
local Camos = require(workspace.Settings.Camos)
LoadoutPackage.__index = LoadoutPackage
function LoadoutPackage.new(...)
local self = {}
local args = {...}
self.Name = args[1]
self.Description = args[2]
self.Primary = Slot.new(args[3].Name,args[3].CamoId,true)
self.Secondary = Slot.new(args[4].Name,args[4].CamoId,true)
self.Explosive = Slot.new(args[5].Name,args[5].CamoId,false)
self.Gadget = Slot.new(args[6].Name,args[6].CamoId,false)
self.Melee = Slot.new(args[7].Name,args[7].CamoId,false)
self.Cost = {
hasCost = args[8][1] or false;
Type = args[8][2] or "Currency";
ProductId = args[8][3] or 0;
Cost = args[8][4] or 0;
}
self.LoadoutClassName = args[9]
return setmetatable(self,LoadoutPackage)
end
function LoadoutPackage:GetItemFromSlot(plr,slotName)
local item
if slotName == "Primary" then
item = plr.Inventory:FindFirstChild(self.Primary.Name)
elseif slotName == "Secondary" then
item = plr.Inventory:FindFirstChild(self.Secondary.Name)
elseif slotName == "Explosive" then
item = plr.Inventory:FindFirstChild(self.Explosive.Name)
elseif slotName == "Gadget" then
item = plr.Inventory:FindFirstChild(self.Gadget.Name)
elseif slotName == "MeleeName" then
item = plr.Inventory:FindFirstChild(self.Melee.Name)
end
return item
end
function LoadoutPackage:ToLoadoutClass()
local loadoutC = LoadoutClass.new(self.LoadoutClassName,self:GetItemFromSlot("Primary"),self:GetItemFromSlot("Secondary"),self:GetItemFromSlot("Explosive"),self:GetItemFromSlot("Gadget"),self:GetItemFromSlot("Melee"))
if loadoutC then
return loadoutC
end
return nil
end
function LoadoutPackage:ToReplicatedPackage()
local pack = {}
pack.Name = self.Name
pack.Description = self.Description
pack.Primary={Name = self.Primary.Name; Camo = self.Primary.CamoId}
pack.Secondary = {Name = self.Secondary.Name; Camo = self.Secondary.CamoId}
pack.Explosive = {Name = self.Explosive.Name; Camo = self.Explosive.CamoId}
pack.Gadget = {Name = self.Gadget.Name; Camo = self.Gadget.CamoId}
pack.MeleeName = {Name = self.Melee.Name; Camo = self.Melee.CamoId}
pack.Cost = self.Cost
return pack
end
function LoadoutPackage.FromReplicatedLoadoutPackage(pack)
return LoadoutPackage.new(pack.Name,pack.Description,Slot.new(pack.Primary),Slot.new(pack.Secondary),Slot.new(pack.Explosive),Slot.new(pack.Gadget),Slot.new(pack.Melee),{pack.Cost.hasCost,pack.Cost.Type,pack.Cost.ProductId,pack.Cost.Cost})
end
function LoadoutPackage:Apply(plr,...)
local bindableService = require(game.ReplicatedStorage.BindingService)(plr)
if self.Primary then
local camo = Camos[self.Primary.CamoId]
local weapon = self:GetItemFromSlot(plr,"Primary")
if self.Primary.HasCamo then
camo:Apply(weapon)
end
bindableService.send("ChangePrimaryWeapon",plr,weapon)
end
if self.Secondary then
local camo = Camos[self.Secondary.CamoId]
local weapon = self:GetItemFromSlot(plr,"Secondary")
if self.Secondaryt.HasCamo then
camo:Apply(weapon)
end
bindableService.send("ChangeSecondaryWeapon",plr,weapon)
end
if self.Explosive then
local camo = Camos[self.Explosive.CamoId]
local weapon = self:GetItemFromSlot(plr,"Explosive")
if self.Explosive.HasCamo then
camo:Apply(weapon)
end
bindableService.send("ChangeExplosiveWeapon",plr,weapon)
end
if self.Gadget then
local camo = Camos[self.Gadget.CamoId]
local weapon = self:GetItemFromSlot(plr,"Gadget")
if self.Gadget.HasCamo then
camo:Apply(weapon)
end
bindableService.send("ChangeGadgetWeapon",plr,weapon)
end
if self.Melee then
local camo = Camos[self.Melee.CamoId]
local weapon = self:GetItemFromSlot(plr,"Melee")
if self.Melee.HasCamo then
camo:Apply(weapon)
end
bindableService.send("ChangeMeleeWeapon",plr,weapon)
end
end
return LoadoutPackage
local DamageTag = require(game.ReplicatedStorage.DamageTag)
game.CollectionService:AddTag(script.Parent,game.HttpService:GenerateGUID(false))
game.CollectionService:AddTag(script.Parent,"Weapon")
local Plyr = script:WaitForChild("Plyr")
Plyr.Value = game.Players:GetPlayerFromCharacter(script.Parent.Parent) or script.Parent.Parent.Parent
local Network = require(game.ReplicatedStorage.RemoteService.Plugin_Gun)(Plyr.Value,script.Parent.Name,true,script.Parent)
local RemoteService = require(game.ReplicatedStorage.RemoteService)
Network.listen("Server","Send","SetCam_"..Plyr.Value.UserId,function(player, Cam)
script:WaitForChild("Cam").Value = Cam
end)
local RS = game:GetService("RunService")
local BC = BrickColor.new
local FFC = game.FindFirstChild
local PL = game.Players
local Cam = script.Cam.Value
local Char = Plyr.Value.Character
local TOS = CFrame.new().toObjectSpace
local Gun = script.Parent
local Handle = Gun:WaitForChild("Handle")
local RAY = Ray.new
local RANDOM = math.random
local FE = workspace.FilteringEnabled
local V3 = Vector3.new
local CF, CFANG, CFTOS = CFrame.new, CFrame.Angles, CFrame.new().toObjectSpace
local PAIRS = pairs
local S = require(Gun.SETTINGS)
local MIN,MAX = math.min,math.max
local RAD,CEIL,FLOOR = math.rad,math.ceil,math.floor
local NSEQ,CSEQ,OBJ = NumberSequence.new,ColorSequence.new,Instance.new
local UD2 = UDim2.new
local NRANGE = NumberRange.new
local RAY = Ray.new
local JointC0,JointC1
local WS = workspace
local AttributeEffect =require(WS.Settings.AttributeEffect)
local PerLevel = require(WS.Settings.PerLevel)
local gunIgnore
local animWeldC1,animWeldC0
local animWeld
local AvailableScopes = require(script.Parent.SCOPES)
local Optics = require(script.Optics)
local AfterEffects = require(game.ReplicatedStorage.GunLibraries.AfterEffect)
local Grip
local DS = game:GetService("Debris")
function ArcTan(x, y)
local r = math.atan(y / x)
if x < 0 then
r = r + math.pi
end
return r
end
local gbl = require(game.ReplicatedStorage.Global)
local RPGM = require(game.ReplicatedStorage.RPGMathProvider)
local numLerp = function(A, B, Alpha)
return A + (B - A) * Alpha
end
local runAsync = function(threadFunc)
coroutine.resume(coroutine.create(threadFunc))
end
local raycast = WS.FindPartOnRayWithIgnoreList
local function isEnemy(Human)
local Plyr2 = game.Players:GetPlayerFromCharacter(Human.Parent)
if (not Plyr2) then if S.CanDamageNPCs then
if Human.Parent:FindFirstChild("BOT") then
return (require(Human.Parent.BOT).Allegiance ~= Plyr.Value.Allegiance.Value)
end
end
end
return S.AllowFriendlyFire or (Plyr2 ~= nil and (Plyr2.Allegiance.Value ~= Plyr.Value.Allegiance.Value or Plyr2.Neutral))
end
local function Weld(p0,p1,c0,c1,par)
local w = OBJ("Weld")
w.Part0 = p0
w.Part1 = p1
w.C0 = c0 or CF()
w.C1 = c1 or CF()
w.Parent = p0 or par
return w
end
local function Motor(p0,p1,c0,c1,des,vel,par)
local w = OBJ("Motor6D")
w.Part0 = p0
w.Part1 = p1
w.C0 = c0 or CF()
w.C1 = c1 or CF()
w.MaxVelocity = tonumber(vel) or .05
w.DesiredAngle = tonumber(des) or 0
w.Parent = p0 or par
return w
end
Network.listen("Server","Send","SetPlayer_"..Plyr.Value.UserId,function(player, Cam)
script.Plyr.Value = player
end)
local function DisplayDamage(damage,humanoid)
local part2 = OBJ("TextLabel")
part2.Font = "Highway"
part2.FontSize = "Size24"
part2.TextStrokeTransparency = 0
part2.Size = UD2(1,0,1,0)
part2.Position = UD2(0,0,0,0)
part2.BackgroundTransparency = 1
part2.Parent = humanoid.Parent.Head.DamageGUI
runAsync(function()
part2:TweenPosition(UDim2.new(0,0,0,-98))
wait(1)
for i = 1, 20 do
part2.TextTransparency = part2.TextTransparency + 0.05
wait(0.025)
end
end)
if (damage == 0) then
part2.TextColor3 = Color3.new(0,0.5,1)
part2.Text = "Miss!"
else
part2.TextColor3 = Color3.new(1,1,1)
part2.Text = damage
end
end
local function tagHumanoid(humanoid, player, damage, previousHealth, headShot)
local tag
if humanoid.Health < 1 then
tag = DamageTag.new(game.CollectionService:GetTags(humanoid.Parent)[1],previousHealth,game.CollectionService:GetTags(Gun)[1],game.CollectionService:GetTags(player)[1],headShot)
else
tag = DamageTag.new(game.CollectionService:GetTags(humanoid.Parent)[1],damage,game.CollectionService:GetTags(Gun)[1],game.CollectionService:GetTags(player)[1],headShot)
end
tag:MarkEnemy(humanoid)
end
local inList = function(Element, List)
for _, v in PAIRS(List) do
if v == Element then
return true
end
end
return false
end
local INSERT = function(tableObj,item)
tableObj[#tableObj+1] = item
end
local REMOVE = function(tableObj,i)
tableObj[i] = nil
end
local getObject = function(Model, Class, Name)
for _, v in PAIRS(Model:GetChildren()) do
if v:IsA(Class) and v.Name == Name then
return v
end
end
return nil
end
----------------------------------------------------------------------
--------------------[ IGNORE MODEL HANDLING ]-------------------------
----------------------------------------------------------------------
wait(RANDOM(0, 20) * 0.025) --This is to prevent more than one ignoreModel from being created
local blasterEnvironment = require(game.ReplicatedStorage.GunLibraries.BlasterEnv)
----------------------------------------------------------------------
--------------------[ GET WELD CFRAMES ]------------------------------
----------------------------------------------------------------------
for _, v in PAIRS(Gun:GetChildren()) do
if v:IsA("BasePart") and v ~= Handle then
if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end
if (not v:FindFirstChild("weldCF")) then
local weldCF = OBJ("CFrameValue")
weldCF.Name = "weldCF"
weldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame)
weldCF.Parent = v
end
if string.sub(v.Name, 1, 3) == "Mag" then
if (not v:FindFirstChild("magTrans")) then
local magTrans = OBJ("NumberValue")
magTrans.Name = "magTrans"
magTrans.Value = v.Transparency
magTrans.Parent = v
end
end
v.Anchored = true
v.CanCollide = false
end
end
Handle.Anchored = false
Handle.CanCollide = true
Network.listen("Server","Fetch","gunSetup_"..tostring(Plyr.Value.UserId),function(player,Vars)
gunIgnore = OBJ("Model")
gunIgnore.Name = "gunIgnore_"..player.Name
gunIgnore.Parent = blasterEnvironment.GetBlasterEnvFromName("Main").IgnoreModel
local playerFolder = OBJ("Model")
playerFolder.Name = "playerFolder"
playerFolder.Parent = gunIgnore
local BulletStorage = OBJ("Folder")
BulletStorage.Name = "bulletStorage_"..player.Name
BulletStorage.Parent = game.ReplicatedStorage
Gun.BulletStorage.Value = BulletStorage
Vars.Humanoid.AutoRotate = false
Vars.Shoulders.Right.Part1 = nil
Vars.Shoulders.Left.Part1 = nil
local headBase = Instance.new("Part")
headBase.Transparency = 1
headBase.Name = "headBase"
headBase.CanCollide = false
headBase.FormFactor = Enum.FormFactor.Custom
headBase.Size = V3(0.2, 0.2, 0.2)
headBase.BottomSurface = Enum.SurfaceType.Smooth
headBase.TopSurface = Enum.SurfaceType.Smooth
headBase.Parent = playerFolder
local headWeld = OBJ("Motor6D")
headWeld.Part0 = Vars.Torso
headWeld.Part1 = headBase
headWeld.C0 = CF(0, 1.5, 0)
headWeld.Parent = Vars.Torso
local headWeld2 = OBJ("Weld")
headWeld2.Part0 = headBase
headWeld2.Part1 = Vars.Head
headWeld2.Parent = headBase
local animBase = OBJ("Part")
animBase.Transparency = 1
animBase.Name = "animBase"
animBase.CanCollide = false
animBase.FormFactor = Enum.FormFactor.Custom
animBase.Size = V3(0.2, 0.2, 0.2)
animBase.BottomSurface = Enum.SurfaceType.Smooth
animBase.TopSurface = Enum.SurfaceType.Smooth
animBase.Parent = playerFolder
animWeld = Motor(animBase,headBase,nil,nil,nil,nil,nil)
animWeld.Name = "animWeld"
local armBase = OBJ("Part")
armBase.Transparency = 1
armBase.Name = "ArmBase"
armBase.CanCollide = false
armBase.FormFactor = Enum.FormFactor.Custom
armBase.Size = V3(0.2, 0.2, 0.2)
armBase.BottomSurface = Enum.SurfaceType.Smooth
armBase.TopSurface = Enum.SurfaceType.Smooth
armBase.Parent = playerFolder
local ABWeld = Motor(armBase,animBase,nil,nil,nil,nil,nil)
local LArmBase = OBJ("Part")
LArmBase.Transparency = 1
LArmBase.Name = "LArmBase"
LArmBase.CanCollide = false
LArmBase.FormFactor = Enum.FormFactor.Custom
LArmBase.Size = V3(0.2, 0.2, 0.2)
LArmBase.BottomSurface = Enum.SurfaceType.Smooth
LArmBase.TopSurface = Enum.SurfaceType.Smooth
LArmBase.Parent = playerFolder
local RArmBase = OBJ("Part")
RArmBase.Transparency = 1
RArmBase.Name = "RArmBase"
RArmBase.CanCollide = false
RArmBase.FormFactor = Enum.FormFactor.Custom
RArmBase.Size = V3(0.2, 0.2, 0.2)
RArmBase.BottomSurface = Enum.SurfaceType.Smooth
RArmBase.TopSurface = Enum.SurfaceType.Smooth
RArmBase.Parent = playerFolder
local LWeld = Motor(armBase,LArmBase,Vars.armC0[1],Vars.leftArmC1,nil,nil,nil)
LWeld.Name = "LWeld"
local RWeld = Motor(armBase,RArmBase,Vars.armC0[2],Vars.rightArmC1,nil,nil,nil)
RWeld.Name = "RWeld"
local LWeld2 = Motor(LArmBase,Vars.LArm,nil,nil,nil,nil,nil)
LWeld2.Name = "LWeld"
local RWeld2 = Motor(RArmBase,Vars.RArm,nil,nil,nil,nil,nil)
RWeld2.Name = "RWeld"
local LLegWeld = Motor(Vars.Torso,nil,CF(-0.5, -2, 0),nil,nil,nil,nil)
LLegWeld.Name = "LLegWeld"
local RLegWeld = Motor(Vars.Torso,nil,CF(0.5, -2, 0),nil,nil,nil,nil)
RLegWeld.Name = "RLegWeld"
for _, Tab in PAIRS(Vars.gunParts) do
Tab.Obj.Anchored = false
local Weld = OBJ("Motor6D")
Weld.Name = "mainWeld"
Weld.Part0 = Vars.Handle
Weld.Part1 = Tab.Obj
Weld.C0 = Tab.Obj.weldCF.Value
Weld.Parent = Vars.Handle
Tab.Weld = Weld
end
Grip = Instance.new("Motor6D")
Grip.Name = "RightGrip"
Grip.Part0 = Vars.RArm
Grip.Part1 = Handle
Grip.C0 = CF(0, -1, 0) * CFANG(-0.5 * math.pi, 0, 0)
Grip.C1 = S.equipSettings.GripC1
Grip.Parent = Vars.RArm
return gunIgnore, playerFolder, headWeld, headWeld2, animWeld, ABWeld, LWeld, RWeld, LWeld2, RWeld2, LLegWeld, RLegWeld, Vars.gunParts
end)
Network.listen("Server","Send","StartAfterEffect",function(player,AfterEffectType,...)
local Effects = {}
if AfterEffectType == "MuzzleFlash" then
local backWater = Gun:FindFirstChild("MainBack")
if backWater then
for _, v in pairs(backWater:GetChildren()) do
if v.Name:sub(1, 7) == "FlashFX" then
INSERT(Effects,AfterEffects.new("MuzzleFlash",v,"Particle",{
Emit = true;
ParticleCount = 8;
}))
end
end
end
for i = 1,#Gun.Main:GetChildren() do
if Gun.Main:GetChildren()[i].Name:sub(1, 7) == "FlashFX" then
INSERT(Effects,AfterEffects.new("MuzzleFlash",Gun.Main:GetChildren()[i],"Particle",{
Emit = true;
ParticleCount = 8;
}))
end
end
for _, effect in pairs(Effects) do
effect:Play()
end
elseif AfterEffectType == "Bolting" then
Effects[1] = AfterEffects.new("Bolting",{
Gun.Bolt;
Gun.BoltBack;
},"PartAnimation",{
BoltDuration = 0.05;
})
Effects[1]:Play()
elseif AfterEffectType == "FireSound" then
local start = 0
if S.fireSoundSettings then
start = S.fireSoundSettings.Start;
end
Effects[1] = AfterEffects.new("FireSound",FFC(Handle,"FireSound"),"Sound",{
Start = start;
UseRaw = true;
})
Effects[1]:Play()
end
end)
--Network.listen("Server","Fetch","makeBullet_"..Plyr.Value.UserId,function(player,Mode,bulletDirection,Origin,ignoreList,gunIgnore)
-- local Origin = Origin
-- local Char = Gun.Parent
-- local ignoreModel = ignoreList[2]
-- local bulletCF = CF(Origin, Origin + bulletDirection)
-- local Bullet
-- if Mode ~= "STUN" then
--
-- Bullet = OBJ("Part")
--
-- Bullet.BrickColor = S.bulletSettings.Color
-- Bullet.Material = Enum.Material.Neon
-- Bullet.Name = "Bullet"
-- Bullet.CanCollide = false
-- Bullet.Size = S.bulletSettings.Size
-- Bullet.BottomSurface = "Smooth"
-- Bullet.TopSurface = "Smooth"
-- if S.bulletSettings.trueBolt then
-- local Mesh2 = game.ReplicatedStorage.BlasterEffects.boltMesh:Clone()
-- Mesh2.Parent = Bullet
--
-- end
-- if not S.bulletSettings.trueBolt then
-- if MIN(S.bulletSettings.Size.X, S.bulletSettings.Size.Y, S.bulletSettings.Size.Z) < 0.2 then
-- local Mesh = OBJ("BlockMesh")
--
-- Mesh.Scale = S.bulletSettings.Size / V3(
-- MAX(S.bulletSettings.Size.X, 0.2),
-- MAX(S.bulletSettings.Size.Y, 0.2),
-- MAX(S.bulletSettings.Size.Z, 0.2)
-- )
-- Mesh.Parent = Bullet
--
-- end
--
-- end
-- else
-- Bullet = game.ReplicatedStorage.StunBullet:Clone()
-- end
--
-- local BF = OBJ("BodyForce")
-- BF.force = V3(0, Bullet:GetMass() * (196.2 - S.bulletSettings.Acceleration), 0)
-- local BV = OBJ("BodyVelocity")
-- BV.MaxForce = V3(1000000,10000000,10000000)
-- BV.Velocity = bulletDirection * S.bulletSettings.Velocity
-- BV.Parent = Bullet
-- BF.Parent = Bullet
-- Bullet.Parent = gunIgnore
-- Bullet.CFrame = bulletCF + bulletDirection * S.bulletSettings.Size.Z / 2
-- return Bullet
--end)
Network.listen("Server","Fetch","unSetupGun_"..Plyr.Value.UserId,function(player,gunParts)
for _, Tab in PAIRS(gunParts) do
Tab.Weld:Destroy()
Tab.Weld = nil
end
return true
end)
Network.listen("Server","Fetch","Arms_"..tostring(Plyr.Value.UserId),function(player,Vars)
local armModel = OBJ("Model")
armModel.Parent = (FE and Vars.gunIgnore.playerFolder or script.Cam.Value)
local fakeLArm = Vars.LArm:Clone()
fakeLArm.Parent = armModel
--fakeLArm.Transparency = Vars.S.fakeArmSettings.Transparency
fakeLArm.CanCollide = false
fakeLArm.Size = Vars.S.fakeArmSettings.armSize
fakeLArm:BreakJoints()
-- Vars.LArm.Transparency = 1
local fakeLWeld = OBJ("Motor6D")
fakeLWeld.Name = "FLWeld"
fakeLWeld.Part0 = fakeLArm
fakeLWeld.Part1 = Vars.LArm
fakeLWeld.Parent = fakeLArm
local fakeRArm = Vars.RArm:Clone()
fakeRArm.Parent = armModel
fakeRArm.Transparency = Vars.S.fakeArmSettings.Transparency
fakeRArm.CanCollide = false
fakeRArm.Size = Vars.S.fakeArmSettings.armSize
fakeRArm:BreakJoints()
--Vars.RArm.Transparency = 1
if Vars.S.fakeArmSettings.showArmor then
if Gun.Parent:FindFirstChild("Arm1") then
local fakeArm1 = Gun.Parent.Arm1:Clone()
fakeArm1.Parent = Vars.gunIgnore
local C = fakeArm1:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i]:IsA('UnionOperation') then
local W = OBJ("Weld")
W.Part0 = fakeArm1.Middle
W.Part1 = C[i]
local CJ = CF(fakeArm1.Middle.Position)
local C0 = fakeArm1.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = fakeArm1.Middle
end
local Y = OBJ("Weld")
Y.Part0 = fakeLArm
Y.Part1 = fakeArm1.Middle
Y.C0 = CF(0, 0, 0)
Y.Parent = Y.Part0
end
local h = fakeArm1:GetChildren()
for i = 1, # h do
if h[i]:IsA("BasePart") then
h[i].Anchored = false
h[i].CanCollide = false
end
end
fakeLArm.Transparency = 1
end
if Gun.Parent:FindFirstChild("Arm2") then
local fakeArm2 = Gun.Parent.Arm2:Clone()
fakeArm2.Parent = Vars.gunIgnore
local C = fakeArm2:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i]:IsA('UnionOperation') then
local W = OBJ("Weld")
W.Part0 = fakeArm2.Middle
W.Part1 = C[i]
local CJ = CF(fakeArm2.Middle.Position)
local C0 = fakeArm2.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = fakeArm2.Middle
end
local Y = OBJ("Weld")
Y.Part0 = fakeRArm
Y.Part1 = fakeArm2.Middle
Y.C0 = CF(0, 0, 0)
Y.Parent = Y.Part0
end
fakeRArm.Transparency = 1
local h = fakeArm2:GetChildren()
for i = 1, # h do
if h[i]:IsA("BasePart") then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end
local fakeRWeld = OBJ("Motor6D")
fakeRWeld.Name = "FRWeld"
fakeRWeld.Part0 = fakeRArm
fakeRWeld.Part1 = Vars.RArm
fakeRWeld.Parent = fakeRArm
local gIgnoreHum = OBJ("Humanoid")
gIgnoreHum.Parent = armModel
if Vars.S.fakeArmSettings.characterMeshes then
for _,Obj in PAIRS(Gun.Parent:GetChildren()) do
if Obj:IsA("CharacterMesh") then
Obj:Clone().Parent = armModel
end
end
end
for _,Obj in PAIRS(Gun.Parent:GetChildren()) do
if Obj:IsA("Shirt") then
Obj:Clone().Parent = armModel
end
end
return armModel
end)
Network.listen("Server","Fetch","Blood_"..Plyr.Value.UserId,function(player, H, P, D, gunIgnore, S)
local bloodCF = CF(P, P + D) * CFANG(RAD(-90), 0, 0)
local Blood = OBJ("Part")
Blood.Transparency = 1
Blood.Anchored = true
Blood.CanCollide = false
Blood.FormFactor = "Custom"
Blood.Size = V3(0.2, 1, 0.2)
Blood.TopSurface = 0
Blood.BottomSurface = 0
local Particles = OBJ("ParticleEmitter")
Particles.Color = CSEQ(S.bloodSettings.Color)
Particles.LightEmission = 0
Particles.Size = NSEQ(S.bloodSettings.Size)
Particles.Texture = S.bloodSettings.Texture
Particles.Transparency = NSEQ(
{
NumberSequenceKeypoint.new(0, S.bloodSettings.startTransparency);
NumberSequenceKeypoint.new(1, 1);
}
)
Particles.EmissionDirection = Enum.NormalId.Top
Particles.Lifetime = NRANGE(S.bloodSettings.Lifetime - 0.05, S.bloodSettings.Lifetime + 0.05)
Particles.Rate = S.bloodSettings.Rate
Particles.Rotation = NRANGE(0, 90)
Particles.Speed = NRANGE(S.bloodSettings.Speed)
Particles.VelocitySpread = S.bloodSettings.Spread
Particles.Parent = Blood
Blood.Parent = gunIgnore
Blood.CFrame = bloodCF
if (not H.Anchored) then
local Weld = OBJ("Weld", Blood)
Weld.Part0 = H
Weld.Part1 = Blood
Weld.C0 = H.CFrame:toObjectSpace(bloodCF)
Blood.Anchored = false
end
delay(0.15, function()
Particles.Enabled = false
wait(S.bloodSettings.Lifetime + 0.05)
Blood:Destroy()
end)
return true
end)
--Network.listen("Server","Fetch","Trail_"..Plyr.Value.UserId,function(player,Origin, P, gunIgnore, S)
-- local Trail = OBJ("Part")
-- Trail.BrickColor = S.trailSettings.Color
-- Trail.Transparency = S.trailSettings.Transparency
-- Trail.Anchored = true
-- Trail.CanCollide = false
-- Trail.Size = V3(1, 1, 1)
-- local Mesh = OBJ("CylinderMesh")
-- Mesh.Offset = V3(0, -(P - Origin).magnitude / 2, 0)
-- Mesh.Scale = V3(S.trailSettings.Thickness, (P - Origin).magnitude, S.trailSettings.Thickness)
-- Mesh.Parent = Trail
-- Trail.Parent = gunIgnore
-- Trail.CFrame = CF(Origin, P) * CFANG(RAD(90), 0, 0)
-- delay(S.trailSettings.visibleTime, function()
-- if S.trailSettings.disappearTime > 0 then
-- local t0 = tick()
-- while true do
-- local Alpha = math.min((tick() - t0) / S.trailSettings.disappearTime, 1)
-- Trail.Transparency = numLerp(S.trailSettings.Transparency, 1, Alpha)
-- if Alpha == 1 then break end
-- RS.Heartbeat:wait()
-- end
-- Trail:Destroy()
-- else
-- Trail:Destroy()
-- end
-- end)
-- result = true
--
--end)
local function Damage(player,Humanoid,H, P, N, D, Dist, customIgnore, mode )
local hVal = S.damageSettings.Multipliers.Head
local cVal = S.damageSettings.Multipliers.Chest
local lVal = S.damageSettings.Multipliers.Limbs
if Humanoid.Health ~= 0 then
local hitHumanoid = nil
if not H then return end
if H.Parent ~= nil then
if H.Parent:IsA("Accoutrement") or H.Parent:FindFirstChild("Middle") then
INSERT(customIgnore, H)
local newRay = RAY(P - D * 0.1, D * (S.bulletSettings.Range - Dist + 0.1))
local newH, newP, newN = raycast(WS,newRay, customIgnore)
if newH then
hitHumanoid = Damage(player, Humanoid, newH, newP, newN, D, Dist + (newP - P).magnitude, customIgnore)
end
else
hitHumanoid = gbl:FindFirstClass(H.Parent, "Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid,player) then
if mode ~= "STUN" then
local chosenDamage = 0
local headShot = false
if H.Name == "Head" then
headShot = true
chosenDamage = RPGM.Combat.HeadshotOffset(script.Parent.Damage.Value,RANDOM(script.Parent.HeadshotDamageMagnitude.Value/(2 - (hVal/Plyr.Value.attributes.Dexterity.Value)),script.Parent.HeadshotDamageMagnitude.Value)) * (hVal + 0.1)
elseif H.Name == "Torso" then
chosenDamage = (RPGM.Combat.RangedPower(Plyr.Value.leaderstats.Lvl.Value,Plyr.Value.attributes.Dexterity.Value,RANDOM(script.Parent.Damage.Value/(2 - (cVal/Plyr.Value.attributes.Dexterity.Value)),script.Parent.Damage.Value)))
else
chosenDamage = (RPGM.Combat.RangedPower(Plyr.Value.leaderstats.Lvl.Value,Plyr.Value.attributes.Dexterity.Value,RANDOM(script.Parent.Damage.Value/(2 - (lVal/Plyr.Value.attributes.Dexterity.Value)),script.Parent.Damage.Value)))
end
local sniperRand
if H.Name == "Head" and S.sniperDamage then
sniperRand = RANDOM(1,2)
chosenDamage = (sniperRand == 2 and hitHumanoid.Health or chosenDamage)
end
local damageHum = 0
if hitHumanoid.Parent:FindFirstChild("SwordScript",true) then
if hitHumanoid.Parent:FindFirstChild("SwordScript",true).Parent:FindFirstChild("Deflecting") then
if hitHumanoid.Parent:FindFirstChild("SwordScript",true).Parent:FindFirstChild("Deflecting").Value then
damageHum = RANDOM(1,2)
end
end
else
damageHum = 1
end
if damageHum ~= 0 and damageHum == 1 then
tagHumanoid(hitHumanoid,player,chosenDamage,hitHumanoid.Health,headShot)
hitHumanoid:TakeDamage(chosenDamage)
elseif damageHum ~= 0 and damageHum == 2 then
Humanoid:TakeDamage(chosenDamage*2)
script.DeflectionSound:Play()
elseif damageHum == 0 then
tagHumanoid(hitHumanoid,player,chosenDamage,hitHumanoid.Health)
hitHumanoid:TakeDamage(chosenDamage)
end
Network.send("Client",player,"markHit_"..Plyr.Value.UserId)
if hitHumanoid.Parent.Head:FindFirstChild("DamageGUI") then
DisplayDamage(chosenDamage,hitHumanoid)
end
if not game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)and hitHumanoid.Name == "Human" then
end
else
hitHumanoid.PlatformStand = true
end
end
end
return hitHumanoid
end
end
end
Network.setupDamageListener(Damage)
function Map(Val, fromLow, fromHigh, toLow, toHigh)
return (Val - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow
end
function getBaseDamage(Dist)
local startDmg = S.damageSettings.Start.Damage
local startDist = S.damageSettings.Start.Dist
local endDmg = S.damageSettings.End.Damage
local endDist = S.damageSettings.End.Dist
return (
(
Dist < startDist * S.bulletSettings.Range
) and startDmg or
(
Dist >= startDist * S.bulletSettings.Range and
Dist < endDist * S.bulletSettings.Range
) and numLerp(startDmg, endDmg, Map(Dist / S.bulletSettings.Range, startDist, endDist, 0, 1)) or
(
Dist >= endDist * S.bulletSettings.Range
) and endDmg
)
end
local function makeImpact(player, H, P, N, D, humanoidFound, gunIgnore)
local surfaceCF =CF(P,P + N)
if not H then return end
----------------------------------------------------------------------------------
--Creating the bullet hole--------------------------------------------------------
----------------------------------------------------------------------------------
if S.bulletHoles and ((not humanoidFound)) then
local Hole = OBJ("Part")
Hole.Transparency = 1
Hole.Anchored = true
Hole.CanCollide = false
Hole.Size = V3(1, 1, 0.2)
Hole.TopSurface = 0
Hole.BottomSurface = 0
local Mesh = OBJ("BlockMesh")
Mesh.Offset = V3(0, 0, -0.05)
Mesh.Scale = V3(S.holeSettings.Size, S.holeSettings.Size, 0)
Mesh.Parent = Hole
local Decal = OBJ("Decal")
Decal.Face = Enum.NormalId.Front
Decal.Texture = S.holeSettings.Texture
Decal.Parent = Hole
Hole.Parent = gunIgnore
Hole.CFrame = surfaceCF
if (not H.Anchored) then
local Weld = OBJ("Weld")
Weld.Part0 = H
Weld.Part1 = Hole
Weld.Parent = Hole
Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
Hole.Anchored = false
end
delay(S.holeSettings.visibleTime, function()
if S.holeSettings.disappearTime > 0 then
local t0 = tick()
while true do
local Alpha = math.min((tick() - t0) / S.holeSettings.disappearTime, 1)
Decal.Transparency = numLerp(0, 1, Alpha)
if Alpha == 1 then break end
RS.Heartbeat:wait()
end
Hole:Destroy()
else
Hole:Destroy()
end
end)
end
----------------------------------------------------------------------------------
--Creating the spark effect-------------------------------------------------------
----------------------------------------------------------------------------------
if S.bulletSparks and (not humanoidFound) and inList(H.Material, S.sparkSettings.Materials) then
local Sparks = OBJ("Part")
Sparks.Transparency = 1
Sparks.Anchored = true
Sparks.CanCollide = false
Sparks.FormFactor = "Custom"
Sparks.Size = V3(1, 1, 1)
Sparks.TopSurface = 0
Sparks.BottomSurface = 0
local Particles = nil
if S.customSparks then
Particles = getObject(game.ServerStorage, "ParticleEmitter", "bulletSpark"):Clone()
else
Particles = OBJ("ParticleEmitter")
Particles.Color = CSEQ(S.sparkSettings.Color.Start, S.sparkSettings.Color.End)
Particles.LightEmission = 1
Particles.Size = NSEQ(
{
NumberSequenceKeypoint.new(0, S.sparkSettings.Size, 0.25);
NumberSequenceKeypoint.new(1, 0);
}
)
Particles.Texture = S.sparkSettings.Texture
Particles.Transparency = NSEQ(0)
Particles.Acceleration = V3(0, -196.2, 0)
Particles.EmissionDirection = Enum.NormalId.Front
Particles.Lifetime = NRANGE(S.sparkSettings.Lifetime - 0.05, S.sparkSettings.Lifetime + 0.05)
Particles.Rate = S.sparkSettings.Rate
Particles.Rotation = NRANGE(0, 360)
Particles.Speed = NRANGE(S.sparkSettings.Speed - 5, S.sparkSettings.Speed + 5)
Particles.VelocitySpread = S.sparkSettings.Spread
end
Particles.Enabled = false
Particles.Parent = Sparks
Sparks.Parent = gunIgnore
Sparks.CFrame = surfaceCF
if (not H.Anchored) then
local Weld = OBJ("Motor6D")
Weld.Part0 = H
Weld.Part1 = Sparks
Weld.Parent = Sparks
Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
Sparks.Anchored = false
end
Particles:Emit(8)
wait(Particles.Lifetime.Max)
Sparks:Destroy()
end
----------------------------------------------------------------------------------
--Creating the smoke effect-------------------------------------------------------
----------------------------------------------------------------------------------
if S.bulletSmoke and (not humanoidFound) then
local Smoke = OBJ("Part")
Smoke.Transparency = 1
Smoke.Anchored = true
Smoke.CanCollide = false
Smoke.FormFactor = "Custom"
Smoke.Size = V3(1, 1, 1)
Smoke.TopSurface = 0
Smoke.BottomSurface = 0
local Particles = OBJ("ParticleEmitter")
Particles.Color = CSEQ(S.smokeSettings.objColor and H.Color or S.smokeSettings.Color)
Particles.LightEmission = 0
Particles.Size = NSEQ(
{
NumberSequenceKeypoint.new(0, S.smokeSettings.Size.Start);
NumberSequenceKeypoint.new(1, S.smokeSettings.Size.End);
}
)
Particles.Texture = S.smokeSettings.Texture
Particles.Transparency = NSEQ(
{
NumberSequenceKeypoint.new(0, S.smokeSettings.startTransparency);
NumberSequenceKeypoint.new(0.5, 0.75 * S.smokeSettings.startTransparency + 0.25);
NumberSequenceKeypoint.new(1, 1);
}
)
Particles.Acceleration = V3(0, -196.2, 0)
Particles.EmissionDirection = Enum.NormalId.Front
Particles.Lifetime = NRANGE(S.smokeSettings.Lifetime - 0.05, S.smokeSettings.Lifetime + 0.05)
Particles.Rate = S.smokeSettings.Rate
Particles.Rotation = NRANGE(0, 360)
Particles.RotSpeed = NRANGE(10)
Particles.Speed = NRANGE(S.smokeSettings.Speed - 5, S.smokeSettings.Speed + 5)
Particles.VelocitySpread = S.smokeSettings.Spread
Particles.Parent = Smoke
Smoke.Parent = gunIgnore
Smoke.CFrame = surfaceCF
if (not H.Anchored) then
local Weld = OBJ("Motor6D")
Weld.Part0 = H
Weld.Part1 = Smoke
Weld.Parent = Smoke
Weld.C0 = CFTOS(H.CFrame,surfaceCF)
Smoke.Anchored = false
end
Particles:Emit(7)
wait(S.smokeSettings.Lifetime + 0.05)
Smoke:Destroy()
end
end
Network.listen("Server","Send","bulletImpact_"..Plyr.Value.UserId,makeImpact)
Network.listen("Server","Send","SetJointC0_"..Plyr.Value.UserId,function(player,Joint, C0)
Joint.C0 = C0
end)
Network.listen("Server","Send","SetJointC1_"..Plyr.Value.UserId,function(player,Joint,C1)
Joint.C1 = C1
end)
Network.listen("Server","Send","changeGripC1_"..Plyr.Value.UserId,function(player,Grip,GripC1)
Grip.C1 = GripC1
end)
Network.listen("Server","Send","changeAnimC1_"..Plyr.Value.UserId,function(player,animWeld,animC0,animC1)
animWeld.C0 = animC0
animWeld.C1 = animC1
end)
Network.listen("Server","Send","destroyGunIgnore_"..Plyr.Value.UserId,function(player,gunIgnore)
gunIgnore:Destroy()
end)
local function makeShockwave(player,Center, Radius, gunIgnore, S)
local Shockwave = OBJ("Part")
Shockwave.BrickColor = S.shockwaveSettings.Color
Shockwave.Material = Enum.Material.SmoothPlastic
Shockwave.Name = "Shockwave"
Shockwave.Anchored = true
Shockwave.CanCollide = false
Shockwave.FormFactor = Enum.FormFactor.Symmetric
Shockwave.Size = V3(1, 1, 1)
Shockwave.BottomSurface = Enum.SurfaceType.Smooth
Shockwave.TopSurface = Enum.SurfaceType.Smooth
local Mesh = OBJ("SpecialMesh")
Mesh.MeshType = Enum.MeshType.Sphere
Mesh.Scale = V3()
Mesh.Parent = Shockwave
Shockwave.Parent = gunIgnore
Shockwave.CFrame = CF(Center)
runAsync(function()
local t0 = tick()
while true do
local Alpha = math.min((tick() - t0) / S.shockwaveSettings.Duration, 1)
local Scale = 2 * Radius * Alpha
Mesh.Scale = V3(Scale, Scale, Scale)
Shockwave.Transparency = Alpha
if Alpha == 1 then break end
RS.Heartbeat:wait()
end
Shockwave:Destroy()
end)
end
Network.listen("Server","Send","Shockwave_"..Plyr.Value.UserId,makeShockwave)
Network.listen("Server","Send","FireExplosive_"..Plyr.Value.UserId,function(player,gunIgnore,H,P,N,bulletDirection,Ignore)
if S.gunType.Explosive then
if S.explosionSettings.soundId ~= "" then
local soundPart = OBJ("Part")
soundPart.Transparency = 1
soundPart.Anchored = true
soundPart.CanCollide = false
soundPart.Size = V3(1, 1, 1)
soundPart.CFrame = CF(P)
soundPart.Parent = gunIgnore
local Sound = OBJ("Sound")
Sound.Pitch = S.explosionSettings.Pitch
Sound.SoundId = S.explosionSettings.soundId
Sound.Volume = S.explosionSettings.Volume
Sound.Parent = soundPart
Sound:Play()
DS:AddItem(soundPart, Sound.TimeLength)
end
makeImpact(player, H, P, N, bulletDirection, false, gunIgnore, S)
makeShockwave(player, P, S.explosionSettings.Radius, gunIgnore, S)
local E = OBJ("Explosion")
E.BlastPressure = S.explosionSettings.Pressure
E.BlastRadius = S.explosionSettings.Radius
E.DestroyJointRadiusPercent = (S.explosionSettings.rangeBasedDamage and 0 or 1)
E.ExplosionType = S.explosionSettings.Type
E.Position = P
E.Hit:connect(function(Obj, Dist)
if Obj.Name == "Torso" and (not Obj:IsDescendantOf(Char)) then
if S.explosionSettings.rangeBasedDamage then
local Dir = (Obj.Position - P).unit
local expH, _ = workspace:FindPartOnRayWithIgnoreList(
RAY(P - Dir * 0.1, Dir * 999),
Ignore
)
local rayHitHuman = expH:IsDescendantOf(Obj.Parent)
if (S.explosionSettings.rayCastExplosions and rayHitHuman) or (not S.explosionSettings.rayCastExplosions) then
local hitHumanoid = Obj.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
local distFactor = (Dist / S.explosionSettings.Radius) + (player.Attributes.Dexterity.Value / S.explosionSettings.Radius)
local distInvert = math.max(1 - distFactor,0)
local newDamage = distInvert * getBaseDamage((P - Gun.Main.CFrame.p).magnitude)
tagHumanoid(hitHumanoid,player,newDamage,hitHumanoid.Health)
hitHumanoid:TakeDamage(newDamage)
Network.send("Client",player,"markHit_"..Plyr.Value.UserId)
end
end
else
local hitHumanoid = Obj.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
tagHumanoid(hitHumanoid,player,hitHumanoid.Health,hitHumanoid.Health)
Network.send("Client",player,"markHit_"..player.UserId)
end
end
end
end)
E.Parent = game.Workspace
end
end)
Network.listen("Server","Send","ShowRegularArms",function(player,LArm,RArm)
LArm.Transparency = 0
RArm.Transparency = 0
end)
Network.listen("Server","Send","ChangeRLegWeldC1_"..Plyr.Value.UserId,function(player,RLegWeld,legC1)
RLegWeld.C1 = legC1
end)
Network.listen("Server","Send","changeHeadC1_"..Plyr.Value.UserId,function(player,headWeld, headC1)
headWeld.C1 = headC1
end)
Network.listen("Server","Send","ResetShoulders_"..Plyr.Value.UserId,function(player,Shoulders,LArm,RArm)
Shoulders.Right.Part1 = RArm
Shoulders.Left.Part1 = LArm
end)
Network.listen("Server","Send","DestroyHeadWeld_"..Plyr.Value.UserId,function(player,headWeld)
headWeld:Destroy()
end)
Network.listen("Server","Send","changeLLegWeldC1_"..Plyr.Value.UserId,function(player,LLegWeld, legC1)
LLegWeld.C1 = legC1
end)
Network.listen("Server","Send","RemoveArmModel",function(player,armModel)
armModel:Destroy()
end)
Network.listen("Server","Send","Disarm_"..Plyr.Value.UserId,function(player,part)
local tools = part.Parent
if tools:IsA("Tool") and isEnemy(tools.Parent:FindFirstChildOfClass("Humanoid")) then
tools.Parent = game.Workspace
local BAV = Instance.new("BodyAngularVelocity")
BAV.Name = "Flip"
BAV.Parent = tools.Handle
local BV = Instance.new("BodyVelocity")
BV.MaxForce = V3(4e6,4e6,4e6)
BV.Velocity = Handle.CFrame.upVector * 20
BV.Parent = tools.Handle
BAV.AngularVelocity = V3(1,1,1) * RAD(RANDOM(1,360))
delay(4,function()
BAV:Destroy()
BV:Destroy()
end)
end
end)
Network.listen("Server","Send","changeRWeldC1_"..Plyr.Value.UserId,function(player, RWeld,rC1)
RWeld.C1 = rC1
end)
Network.listen("Server","Send","changeLWeldC1_"..Plyr.Value.UserId,function(player, LWeld,lC1)
LWeld.C1 = lC1
end)
Network.listen("Server","Send","ReplicateBullet_"..Plyr.Value.UserId,function(player,className,Direction,gunIgnore,bCFrame)
RemoteService.bounceOthers("Client",player,"MakeBullet",player,className,Direction,gunIgnore,bCFrame,S)
end)
Network.listen("Server","Fetch","GetCurrentBullet_"..Plyr.Value.UserId,function(player)
return Gun.BulletObj.Value
end)
Network.listen("Server","Send","CreateArmor",function(player,fakeLArm,fakeRArm)
if S.fakeArmSettings.showArmor then
if Char:FindFirstChild("Arm1") then
local fakeArm1 = (Char.Arm1):Clone()
fakeArm1.Parent = gunIgnore
local C = fakeArm1:GetChildren()
for i=1, #C do
if C[i]:IsA("BasePart") then
local W = OBJ("Motor6D")
W.Part0 = fakeArm1.Middle
W.Part1 = C[i]
local CJ = CF(fakeArm1.Middle.Position)
local C0 = (fakeArm1.Middle.CFrame):inverse()*CJ
local C1 = (C[i].CFrame):inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = fakeArm1.Middle
end
local Y = OBJ("Motor6D")
Y.Part0 = fakeLArm
Y.Part1 = fakeArm1.Middle
Y.C0 = CF(0, 0, 0)
Y.Parent = Y.Part0
end
local h = fakeArm1:GetChildren()
for i = 1, # h do
if h[i]:IsA("BasePart") then
h[i].Anchored = false
h[i].CanCollide = false
end
end
fakeLArm.Transparency = 1
end
if FFC(Char,"Arm2") then
local fakeArm2 = (Char.Arm2):Clone()
fakeArm2.Parent = gunIgnore
local C = (fakeArm2):GetChildren()
for i=1, #C do
if C[i]:IsA("BasePart") then
local W = OBJ.RAW("Weld")
W.Part0 = fakeArm2.Middle
W.Part1 = C[i]
local CJ = CF(fakeArm2.Middle.Position)
local C0 = (fakeArm2.Middle.CFrame):inverse()*CJ
local C1 = CF.Inverse(C[i].CFrame):inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = fakeArm2.Middle
end
local Y = OBJ("Motor6D")
Y.Part0 = fakeRArm
Y.Part1 = fakeArm2.Middle
Y.C0 = CF(0, 0, 0)
Y.Parent = Y.Part0
end
fakeRArm.Transparency = 1
local h = (fakeArm2):GetChildren()
for i = 1, # h do
if h[i]:IsA("BasePart") then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end
end)
--Gun.BulletObj.Changed:connect(function(bullet)
-- if bullet then
-- local Bullet = bullet:Clone()
--
-- end
--end)
local Humanoid = Plyr.Value.Character.Humanoid
local Torso = Plyr.Value.Character.Torso
Network.startServer();
Gun.Equipped:connect(function()
Network.enable()
Optics:SetupScope(Gun.CurrentScope.Value)
local CamoId = Gun.CamoId
for _, part in pairs(Gun:GetChildren()) do
if part:IsA("BasePart") then
if part:FindFirstChildOfClass("Texture") then
for _, texture in pairs(part:GetChildren()) do
if texture:IsA("Texture") then
texture.Texture = CamoId.Value
end
end
end
end
end
end)
Gun.Unequipped:connect(function()
Grip:Destroy()
Network.reset()
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment