Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- local Workspace = game:GetService("Workspace")
- local ServerScriptService = game:GetService("ServerScriptService")
- local MarketplaceService = game:GetService("MarketplaceService")
- local Debris = game:GetService("Debris")
- local DataManager = require(ServerScriptService:WaitForChild("Modules"):WaitForChild("DataManager"))
- local CharacterModule = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("CharacterModule"))
- local StunModule = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("StunModule"))
- local AbilityModule = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("AbilityModule"))
- local ApplyKnockback = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("ApplyKnockBack"))
- local ApplyDamage = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("ApplyDamage"))
- local Config = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("Config"))
- local HIT_ANIM_ID = 85710625600514
- local Remotes = ReplicatedStorage:WaitForChild("Remotes")
- local CharactersFolder = ReplicatedStorage:WaitForChild("Modules"):WaitForChild("CharacterModule"):WaitForChild("Characters")
- local OverlapParameters = OverlapParams.new()
- OverlapParameters.FilterType = Enum.RaycastFilterType.Exclude
- OverlapParameters.FilterDescendantsInstances = {}
- OverlapParameters.CollisionGroup = "Default"
- local function ApplyAnimations(Player: Player, Character: string)
- local CharacterInstance = CharactersFolder:WaitForChild(Character)
- if CharacterInstance then
- local CharAnimate = CharacterInstance:FindFirstChild("Animate"):Clone()
- local PlayerAnimate = Player.Character:FindFirstChild("Animate")
- if CharAnimate and PlayerAnimate then
- CharAnimate.Parent = Player.Character
- PlayerAnimate:Destroy()
- end
- else
- warn("Character Instance Not Found", Character)
- end
- end
- local function Preload(Player: Player)
- local Character = Player.Character
- local Humanoid = Character:FindFirstChildOfClass("Humanoid")
- local Animator = Humanoid:FindFirstChildOfClass("Animator")
- for _, Module: ModuleScript in CharactersFolder:GetChildren() do
- if Module:IsA("ModuleScript") then
- local RequiredModule = require(Module)
- local Animations = RequiredModule.Animations
- for Name: string, Animation: number in pairs(Animations) do
- if Name == "PunchAnimations" then
- for AbilityNum, PunchAnimation: number in pairs(Animation) do
- local Anim = Instance.new("Animation")
- Anim.AnimationId = `rbxassetid://{PunchAnimation}`
- Animator:LoadAnimation(Anim)
- end
- else
- local Anim = Instance.new("Animation")
- Anim.AnimationId = `rbxassetid://{Animation}`
- Animator:LoadAnimation(Anim)
- end
- end
- end
- end
- end
- local function ApplyCosmetics(Player: Player, Character: string)
- local CharacterInstance = CharactersFolder:WaitForChild(Character)
- if CharacterInstance then
- local Accessories = CharacterInstance:FindFirstChild("Accessories")
- local TempFolder = Player.Character:FindFirstChild("TempAccessories") or Instance.new("Folder")
- TempFolder.Name = "TempAccessories"
- TempFolder.Parent = Player.Character
- for _, Object in TempFolder:GetChildren() do
- Object:Destroy()
- end
- if Accessories then
- for _, AccessoryFolder in ipairs(Accessories:GetChildren()) do
- if AccessoryFolder:IsA("Model") and AccessoryFolder.Name == "Accessory Template Dummy" then
- for _, BodyPart in AccessoryFolder:GetChildren() do
- local FakeBodyPart: BasePart = BodyPart:Clone()
- FakeBodyPart.Position = Player.Character[BodyPart.Name].Position
- FakeBodyPart.Orientation = Player.Character[BodyPart.Name].Orientation
- local Weld = Instance.new("WeldConstraint")
- Weld.Parent = FakeBodyPart
- Weld.Part0 = Player.Character[BodyPart.Name]
- Weld.Part1 = FakeBodyPart
- FakeBodyPart.Transparency = 1
- FakeBodyPart.Parent = TempFolder
- end
- end
- end
- end
- else
- warn("Character Instance Not Found", Character)
- end
- end
- local function ApplyCharacterStats(Player: Player, CharacterTable)
- Player:SetAttribute("Atk_Dmg", CharacterTable.Atk.Dmg)
- Player:SetAttribute("Health", CharacterTable.Health)
- Player:SetAttribute("WalkSpeed_Mult", CharacterTable.SpeedMult)
- local Character = Player.Character
- Character:SetAttribute("LastHitBy", "")
- local Humanoid: Humanoid = Character:FindFirstChildOfClass("Humanoid")
- if Humanoid then
- Humanoid.WalkSpeed = Config.NormalWalkSpeed * CharacterTable.SpeedMult
- Humanoid.MaxHealth = CharacterTable.Health
- Humanoid.Health = CharacterTable.Health
- else
- warn("Humanoid Not Found In Character")
- end
- Player.UltActive.Value = false
- AbilityModule:Cleanup(Player)
- task.wait(0.2)
- AbilityModule:SetupCharacter(Player, CharacterTable)
- ApplyAnimations(Player, CharacterTable.Name)
- ApplyCosmetics(Player, CharacterTable.Name)
- end
- local function BoxCastTargets(AttackerChar: Model, Size: Vector3, ForwardOffset: number, Params: OverlapParams)
- local HRP = AttackerChar:FindFirstChild("HumanoidRootPart")
- if not HRP then return {} end
- local CF = HRP.CFrame * CFrame.new(0, 0, -ForwardOffset)
- return Workspace:GetPartBoundsInBox(CF, Size, Params)
- end
- local function GetVictimCharacterFromPart(Part: BasePart)
- if not Part then return nil end
- local M = Part:FindFirstAncestorOfClass("Model")
- if not M then return nil end
- if M:FindFirstChildOfClass("Humanoid") then
- return M
- end
- return nil
- end
- local function IsBlockingTarget(TargetChar: Model)
- local Player = Players:GetPlayerFromCharacter(TargetChar)
- if Player then
- return Player:GetAttribute("Blocking") == true
- end
- local BV = TargetChar:FindFirstChild("Blocking")
- return (BV and BV:IsA("BoolValue") and BV.Value) or false
- end
- local function AttachBlockVFX(TargetChar: Model)
- local VFXPart = ReplicatedStorage:FindFirstChild("VFX") and ReplicatedStorage.VFX:FindFirstChild("Block")
- if not VFXPart then return end
- local HRP = TargetChar:FindFirstChild("HumanoidRootPart")
- if not HRP then return end
- local Clone = VFXPart:Clone()
- Clone.CFrame = HRP.CFrame
- Clone.Parent = TargetChar
- local Weld = Instance.new("WeldConstraint", Clone)
- Weld.Part0 = HRP
- Weld.Part1 = Clone
- local Attachment = Clone:FindFirstChildOfClass("Attachment")
- if Attachment then
- for _, V in ipairs(Attachment:GetChildren()) do
- if V:IsA("ParticleEmitter") then
- V:Emit(1)
- end
- end
- end
- Debris:AddItem(Clone, 2)
- end
- local function ApplyM1Results(Attacker: Player, VictimChar: Model, Damage: number, KBRange: number, KBHeight: number, Heavy: boolean)
- if not VictimChar then
- return
- end
- local Hum = VictimChar:FindFirstChildOfClass("Humanoid")
- if not Hum then
- return
- end
- VictimChar:SetAttribute("LastHitBy", Attacker.Name)
- if IsBlockingTarget(VictimChar) then
- StunModule.HitEffectsBlocking(VictimChar)
- AttachBlockVFX(VictimChar)
- return
- end
- Hum:TakeDamage(Damage)
- Attacker.UltPoints.Value += (Damage ^ 1.05)
- StunModule.ApplyStunAndEffects(VictimChar, 1, HIT_ANIM_ID, true, true)
- local AttackerChar = Attacker.Character
- if AttackerChar then
- local KB = ApplyKnockback.new(VictimChar, AttackerChar, KBRange, KBHeight)
- KB:Construct()
- end
- if Heavy then
- local Rag = VictimChar:FindFirstChild("IsRagdoll")
- if Rag and Rag:IsA("BoolValue") then
- Rag.Value = true
- task.delay(1, function()
- if Rag then
- Rag.Value = false
- end
- end)
- end
- end
- end
- Players.PlayerAdded:Connect(function(Player: Player)
- local Characters = CharacterModule.GetCharacters(Player)
- local SelectedCharacter = Player:WaitForChild("SelectedCharacter").Value
- local CharInfo = CharacterModule.GetCharacterInfo(Player, SelectedCharacter)
- local function ApplyStatsOnRespawn()
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid: Humanoid = Character:FindFirstChild("Humanoid")
- ApplyCharacterStats(Player, CharInfo)
- Preload(Player)
- Humanoid.Died:Connect(function()
- Player.CharacterAdded:Wait()
- ApplyCharacterStats(Player, CharInfo)
- end)
- end
- Remotes.ChangeCharacter:FireClient(Player, CharInfo)
- ApplyStatsOnRespawn()
- end)
- Remotes.ChangeCharacter.OnServerEvent:Connect(function(Player: Player, Character: string)
- if Player and Character then
- if tostring(Player.SelectedCharacter.Value):lower() == tostring(Character):lower() then
- warn(`Character: {tostring(Character)} Is Already Equipped!`)
- return
- end
- local Profile = DataManager.Profiles[Player]
- local CharInfo = CharacterModule.GetCharacterInfo(Player, Character)
- local GamepassID = 1448977557
- if CharInfo.OnEarlyAccess == true then
- if not MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
- MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
- return
- end
- end
- if ReplicatedStorage:WaitForChild("Modules"):WaitForChild("CharacterModule"):WaitForChild("Characters"):FindFirstChild(Character) then
- Profile.Data.SelectedCharacter = Character
- Player:WaitForChild("SelectedCharacter").Value = Profile.Data.SelectedCharacter
- Player:WaitForChild("UltPoints").Value = 0
- ApplyCharacterStats(Player, CharInfo)
- Remotes.ChangeCharacter:FireClient(Player, CharInfo)
- end
- end
- end)
- Remotes.GetCharacterInfo.OnServerInvoke = function(Player: Player)
- local SelectedChar = Player:WaitForChild("SelectedCharacter").Value
- local CharacterDataTable = CharacterModule.GetCharacterInfo(Player, SelectedChar)
- if SelectedChar and CharacterDataTable then
- return SelectedChar, CharacterDataTable
- else
- return nil, {}
- end
- end
- Remotes.Ability.OnServerInvoke = function(Player: Player, AbilityName: string)
- local SelectedCharacter = Player.SelectedCharacter.Value
- if CharactersFolder:FindFirstChild(SelectedCharacter) then
- local CharModule = require(CharactersFolder[SelectedCharacter])
- local CharModuleInstance = CharactersFolder[SelectedCharacter]
- local Moveset
- local AbilityInfoTable
- if Player.UltActive.Value then
- Moveset = CharModule.UltMoveset
- else
- Moveset = CharModule.Moveset
- end
- if Moveset then
- for _, Move in pairs(Moveset) do
- if Move.Name == AbilityName then
- AbilityInfoTable = Move
- break
- end
- end
- end
- if AbilityInfoTable then
- print(AbilityInfoTable)
- return AbilityInfoTable
- else
- warn("Ability not found: " .. AbilityName)
- return {}
- end
- else
- warn("Selected Character Does Not Exist: " .. SelectedCharacter)
- end
- return {}
- end
- Remotes.FireAbility.OnServerEvent:Connect(function(Player: Player, AblityInfoTable)
- local SelectedCharacter = Player.SelectedCharacter.Value
- if AblityInfoTable then
- print(AblityInfoTable)
- local CharModule = require(CharactersFolder[SelectedCharacter])
- local CharModuleInstance = CharactersFolder[SelectedCharacter]
- local AbModule = require(CharModuleInstance.Abilities)
- AbModule:Cast(Player, AblityInfoTable)
- else
- warn("Ability not found: " .. AblityInfoTable.Name)
- return {}
- end
- end)
- Remotes.Knockback.OnServerEvent:Connect(function(Player: Player, EnemyCharacter: Model, Character: Model, Range: number, Height: number)
- local Knockback = ApplyKnockback.new(EnemyCharacter, Character, Range, Height)
- Knockback:Construct()
- end)
- Remotes.Ragdoll.OnServerEvent:Connect(function(Player: Player, IsRagdollValue: BoolValue, Value: boolean)
- IsRagdollValue.Value = Value
- end)
- Remotes.Hit.OnServerEvent:Connect(function(Player: Player, EnemyCharacter: Model, AnimationId: number, Duration: number, Option: string, HitOption: boolean, AnimationOption: boolean)
- if Option == "STUN" then
- StunModule.StunFor(EnemyCharacter, Duration)
- elseif Option == "HIT" then
- StunModule.HitEffects(EnemyCharacter, AnimationId, HitOption, AnimationOption)
- elseif Option == "BLOCKING" then
- StunModule.HitEffectsBlocking(EnemyCharacter)
- elseif Option == "BOTH" then
- StunModule.ApplyStunAndEffects(EnemyCharacter, Duration, AnimationId, HitOption, AnimationOption)
- end
- EnemyCharacter:SetAttribute("LastHitBy", Player.Name)
- end)
- Remotes.Block.OnServerEvent:Connect(function(Player: Player, IsBlocking: boolean)
- Player:SetAttribute("Blocking", IsBlocking == true)
- end)
- Remotes.UltActivated.OnServerEvent:Connect(function(Player: Player)
- local SelectedChar = Player:WaitForChild("SelectedCharacter").Value
- local CharacterDataTable = CharacterModule.GetCharacterInfo(Player, SelectedChar)
- Player.UltPoints.Value = 0
- Player.UltActive.Value = true
- AbilityModule:Cleanup(Player)
- AbilityModule:SetupCharacter(Player, CharacterDataTable)
- end)
- Remotes.UltEnded.OnServerEvent:Connect(function(Player: Player)
- local SelectedChar = Player:WaitForChild("SelectedCharacter").Value
- local CharacterDataTable = CharacterModule.GetCharacterInfo(Player, SelectedChar)
- Player.UltActive.Value = false
- AbilityModule:Cleanup(Player)
- AbilityModule:SetupCharacter(Player, CharacterDataTable)
- end)
- Remotes.AwardTakedown.OnServerEvent:Connect(function(Player: Player, PlayerToAwardTo: Player)
- if Player and PlayerToAwardTo then
- local Profile = DataManager.Profiles[PlayerToAwardTo]
- if Profile then
- Profile.Data.TotalKills += 1
- PlayerToAwardTo.leaderstats["Total Kills"].Value = Profile.Data.TotalKills
- PlayerToAwardTo.leaderstats.Kills.Value += 1
- end
- end
- end)
- Remotes.Attack.OnServerEvent:Connect(function(Player: Player, ComboIndex: number, State: string)
- local AttackerChar = Player.Character
- local Hum = AttackerChar and AttackerChar:FindFirstChildOfClass("Humanoid")
- local HRP = AttackerChar and AttackerChar:FindFirstChild("HumanoidRootPart")
- if not (AttackerChar and Hum and HRP and Hum.Health > 0) then return end
- local SelectedChar = Player:FindFirstChild("SelectedCharacter") and Player.SelectedCharacter.Value
- if not SelectedChar then return end
- local CharInfo = CharacterModule.GetCharacterInfo(Player, SelectedChar)
- if not CharInfo or not CharInfo.Atk or not CharInfo.Atk.Dmg then return end
- local S = Hum:GetState()
- if State == "Slam" then
- local AirBorne = (S == Enum.HumanoidStateType.Freefall or S == Enum.HumanoidStateType.FallingDown or S == Enum.HumanoidStateType.Jumping)
- if not AirBorne then
- State = "Normal"
- end
- end
- OverlapParameters.FilterDescendantsInstances = { AttackerChar }
- local Size, Offset = Vector3.new(5, 5, 5), 4
- local Heavy = false
- local Dmg = CharInfo.Atk.Dmg
- local KBRange, KBHeight = 10, 2
- if ComboIndex == 4 then
- Heavy = true
- Dmg *= Config.HeavyDmgMult
- if State == "Slam" then
- Size = Vector3.new(5, 15, 5)
- KBRange, KBHeight = 1, 5
- elseif State == "Uppercut" then
- Size = Vector3.new(5, 5, 5)
- KBRange, KBHeight = 1, 10
- else
- KBRange, KBHeight = 10, 2
- end
- else
- Size = (State == "Uppercut") and Vector3.new(5, 5, 5) or Vector3.new(5, 5, 5)
- KBRange, KBHeight = 0, 0
- end
- local Parts = BoxCastTargets(AttackerChar, Size, Offset, OverlapParameters)
- local HitVictims = {}
- for _, P in ipairs(Parts) do
- local VictimChar = GetVictimCharacterFromPart(P)
- if VictimChar and VictimChar ~= AttackerChar and not HitVictims[VictimChar] then
- HitVictims[VictimChar] = true
- ApplyM1Results(Player, VictimChar, Dmg, KBRange, KBHeight, Heavy)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment