local Q=game:GetService("\087\111\114\107\115\112\097\099\101")local h=game:GetService("\080\108\097\121\101\114\115")local N=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local H=require(((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\080\114\111\106\101\099\116")):WaitForChild("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101"))local O=H:GetResource("\069\120\116\101\114\110\097\108\085\116\105\108\046\078\101\120\117\115\073\110\115\116\097\110\099\101\046\078\101\120\117\115\079\098\106\101\099\116")local U=H:GetResource("\071\097\109\101\068\097\116\097\046\073\116\101\109\046\065\116\116\097\099\107\115")local T=H:GetResource("\083\116\097\116\101\046\076\101\118\101\108\115")local J=H:GetResource("\071\097\109\101\082\101\112\108\105\099\097\116\105\111\110\046\068\117\110\103\101\111\110\082\101\112\108\105\099\097\116\105\111\110\046\083\116\097\114\116\068\117\110\103\101\111\110")local t=H:GetResource("\071\097\109\101\082\101\112\108\105\099\097\116\105\111\110\046\068\117\110\103\101\111\110\082\101\112\108\105\099\097\116\105\111\110\046\069\110\100\068\117\110\103\101\111\110")local P=H:GetResource("\071\097\109\101\082\101\112\108\105\099\097\116\105\111\110\046\068\117\110\103\101\111\110\082\101\112\108\105\099\097\116\105\111\110\046\080\101\114\102\111\114\109\065\116\116\097\099\107")local b=O:Extend()b:SetClassName("\067\101\110\116\101\114\083\116\097\116\115")function b.__new(H,Q)H:InitializeSuper()local O=Instance.new("\073\109\097\103\101\076\097\098\101\108")O.AnchorPoint=Vector2.new(.27,1)O.Size=UDim2.new(6,0,1.5,0)O.SizeConstraint="\082\101\108\097\116\105\118\101\089\089"O.Position=UDim2.new(.5,0,1.65,0)O.BackgroundTransparency=1 O.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\052\057\051\049"O.Parent=Q local P=Instance.new("\073\109\097\103\101\076\097\098\101\108")P.BackgroundTransparency=1 P.Size=UDim2.new(.5,0,.0625)P.Position=UDim2.new(.141,0,.145,0)P.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\050\057\055"P.Parent=O local b=Instance.new("\073\109\097\103\101\076\097\098\101\108")b.BackgroundTransparency=1 b.Size=UDim2.new(1,0,1,0)b.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\051\051\050"b.Parent=P H.HealthBarFill=b local B=Instance.new("\084\101\120\116\076\097\098\101\108")B.BackgroundTransparency=1 B.Size=UDim2.new(1,0,1.5,0)B.Position=UDim2.new(.08,0,-0.4,0)B.Text="\049\048\048\047\049\048\048"B.Font=Enum.Font.Antique B.TextColor3=Color3.new(.93333333333333,.80392156862745,1.0)B.TextScaled=true B.Parent=P H.HealthText=B h.LocalPlayer.CharacterAdded:Connect(function()H:ConnectHealthBar()end);(coroutine.wrap(function()H:ConnectHealthBar()end))()local L=h.LocalPlayer:WaitForChild("\069\110\101\114\103\121")H.EnergyValue=L local K=Instance.new("\073\109\097\103\101\076\097\098\101\108")K.BackgroundTransparency=1 K.Size=UDim2.new(.5,0,.0625)K.Position=UDim2.new(.141,0,.225,0)K.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\050\057\055"K.Parent=O local W=Instance.new("\073\109\097\103\101\076\097\098\101\108")W.BackgroundTransparency=1 W.Size=UDim2.new(L.Value/100,0,1,0)W.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\048\055\054"W.Parent=K local g=Instance.new("\084\101\120\116\076\097\098\101\108")g.BackgroundTransparency=1 g.Size=UDim2.new(1,0,1.5,0)g.Position=UDim2.new(.08,0,-0.4,0)g.Text=tostring(L.Value).."\047\049\048\048"g.Font=Enum.Font.Antique g.TextColor3=Color3.new(.93333333333333,.80392156862745,1.0)g.TextScaled=true g.Parent=K L.Changed:Connect(function()W:TweenSize(UDim2.new(L.Value/100,0,1,0),"\073\110\079\117\116","\081\117\097\100",.1,true)g.Text=tostring(L.Value).."\047\049\048\048"end)local u=T.GetLevels(h.LocalPlayer)local q=Instance.new("\073\109\097\103\101\076\097\098\101\108")q.BackgroundTransparency=1 q.Size=UDim2.new(.5,0,.0625)q.Position=UDim2.new(.062,0,.51171875,0)q.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\049\050\053"q.Parent=O local I=Instance.new("\073\109\097\103\101\076\097\098\101\108")I.BackgroundTransparency=1 I.Size=UDim2.new((u.TotalExperience-u.PreviousLevelExperience)/(u.NextLevelExperience-u.PreviousLevelExperience),0,1,0)I.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\050\052\057"I.Parent=q local r=Instance.new("\073\109\097\103\101\076\097\098\101\108")r.BackgroundTransparency=1 r.Size=UDim2.new(1,0,1,0)r.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\049\057\051"r.Parent=q local p=Instance.new("\073\109\097\103\101\076\097\098\101\108")p.BackgroundTransparency=1 p.Position=UDim2.new(.01,0,.25,0)p.Size=UDim2.new(.0625,0,.5,0)p.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\055\050\053\049\054\048"p.Parent=q u.Changed:Connect(function()I:TweenSize(UDim2.new((u.TotalExperience-u.PreviousLevelExperience)/(u.NextLevelExperience-u.PreviousLevelExperience),0,1,0),"\073\110\079\117\116","\081\117\097\100",.5,true)end)H.SelectedAttack=1 local y=Instance.new("\070\114\097\109\101")y.BackgroundTransparency=1 y.Size=UDim2.new(.380859375,0,.1640625,0)y.Position=UDim2.new(.080078125,0,.3046875,0)y.Visible=false y.Parent=O H.AttackButtonsContainer=y local v=Instance.new("\073\109\097\103\101\076\097\098\101\108")v.BackgroundTransparency=1 v.Size=UDim2.new(.11794871794872,0,1.0952380952381,0)v.Position=UDim2.new(-0.0051282051282051,0,-0.047619047619048,0)v.ZIndex=3 v.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\051\050\053\049\049\049\050"v.Parent=y H.AttackSelector=v local n,l=0,0 H.AttackButtons={}H.AttackDB=true for Q,h in pairs(U)do local O=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")O.BackgroundTransparency=1 O.Size=UDim2.new(.10769230769231,0,1.0,0)O.Position=UDim2.new((Q-1)*.12820512820513,0,0,0)O.Visible=u.Level>=(h.RequiredLevel or 0)O.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047"..tostring(h.Icon)O.Parent=y H.AttackButtons[Q]=O;(u:GetPropertyChangedSignal("\076\101\118\101\108")):Connect(function()O.Visible=u.Level>=(h.RequiredLevel or 0)end)L.Changed:Connect(function()if L.Value>=(h.EnergyPerUse or 0)then O.ImageColor3=Color3.new(1,1,1)else O.ImageColor3=Color3.new(.5,.5,.5)end end)local U=true O.MouseButton1Down:Connect(function()if U and(y.Visible and O.Visible)then U=false H:SelectWeapon(Q)wait()U=true end end)N.InputBegan:Connect(function(U,T)if T then return end if not y.Visible or not O.Visible then return end if N:GetFocusedTextBox()then return end for h,N in pairs(h.ActivationKeys or{})do if N==U.KeyCode then H:SelectWeapon(Q)H:ActivateWeapon(n,l)break end end end)end N.InputBegan:Connect(function(Q,h)if h then return end if Q.UserInputType==Enum.UserInputType.MouseButton1 or Q.UserInputType==Enum.UserInputType.Touch then H:ActivateWeapon(Q.Position.X,Q.Position.Y)end end)N.InputChanged:Connect(function(Q)if Q.UserInputType==Enum.UserInputType.MouseMovement or Q.UserInputType==Enum.UserInputType.Touch then n,l=Q.Position.X,Q.Position.Y end end)J.OnClientEvent:Connect(function(Q,h,N,H)if H=="\077\111\110\115\116\101\114"or H=="\066\108\111\120\104\105\108\100\097"then y.Visible=true end end)t.OnClientEvent:Connect(function()y.Visible=false end)end function b.ConnectHealthBar(Q)local N=h.LocalPlayer.Character if N then local h=N:WaitForChild("\072\117\109\097\110\111\105\100");(h:GetPropertyChangedSignal("\072\101\097\108\116\104")):Connect(function()Q.HealthBarFill.Size=UDim2.new(h.Health/h.MaxHealth,0,1,0)Q.HealthText.Text=tostring(math.floor(h.Health+.5))..("\047"..tostring(math.floor(h.MaxHealth+.5)))end);(h:GetPropertyChangedSignal("\077\097\120\072\101\097\108\116\104")):Connect(function()Q.HealthBarFill.Size=UDim2.new(h.Health/h.MaxHealth,0,1,0)Q.HealthText.Text=tostring(math.floor(h.Health+.5))..("\047"..tostring(math.floor(h.MaxHealth+.5)))end)Q.HealthBarFill.Size=UDim2.new(h.Health/h.MaxHealth,0,1,0)Q.HealthText.Text=tostring(math.floor(h.Health+.5))..("\047"..tostring(math.floor(h.MaxHealth+.5)))end end function b.SelectWeapon(h,Q)h.SelectedAttack=Q h.AttackSelector.Position=UDim2.new((50*(Q-1)-2)/390,0,-0.047619047619048,0)end function b.ActivateWeapon(T,N,O)if not T.AttackButtonsContainer.Visible then return end if not T.AttackButtons[T.SelectedAttack].Visible then return end if T.AttackButtons[T.SelectedAttack].ImageColor3~=Color3.new(1,1,1)then return end if not T.AttackDB then return end T.AttackDB=false local J=Q.CurrentCamera local t=J:ScreenPointToRay(N,O,10000)local b=t.Origin+t.Direction local B=RaycastParams.new()B.FilterType=Enum.RaycastFilterType.Blacklist B.FilterDescendantsInstances={h.LocalPlayer.Character}local L=Q:Raycast(J.CFrame.Position,b-J.CFrame.Position,B)local K=U[T.SelectedAttack]local W=H:GetResource("\083\116\097\116\101\046\084\111\111\108\046\065\116\116\097\099\107\046"..K.Name)if L then if W.PerformClientAttack then W.PerformClientAttack(L.Position)end P:FireServer(T.SelectedAttack,L.Position)else if W.PerformClientAttack then W.PerformClientAttack(b)end P:FireServer(T.SelectedAttack,b)end wait(K.AttackCooldown or 0)T.AttackDB=true end return b
--[[
TheNexusAvenger

Center stats the bottom bar.
--]]

local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")

local ReplicatedStorageProject = require(game:GetService("ReplicatedStorage"):WaitForChild("Project"):WaitForChild("ReplicatedStorage"))

local NexusObject = ReplicatedStorageProject:GetResource("ExternalUtil.NexusInstance.NexusObject")
local Attacks = ReplicatedStorageProject:GetResource("GameData.Item.Attacks")
local Levels = ReplicatedStorageProject:GetResource("State.Levels")
local StartDungeon = ReplicatedStorageProject:GetResource("GameReplication.DungeonReplication.StartDungeon")
local EndDungeon = ReplicatedStorageProject:GetResource("GameReplication.DungeonReplication.EndDungeon")
local PerformAttack = ReplicatedStorageProject:GetResource("GameReplication.DungeonReplication.PerformAttack")

local CenterStats = NexusObject:Extend()
CenterStats:SetClassName("CenterStats")



--[[
Creates the center stats.
--]]
function CenterStats:__new(BottomFrame)
    self:InitializeSuper()
    
    --Create the stats containers.
    local StatsBarBackground = Instance.new("ImageLabel")
    StatsBarBackground.AnchorPoint = Vector2.new(0.27,1)
    StatsBarBackground.Size = UDim2.new(6,0,1.5,0)
    StatsBarBackground.SizeConstraint = "RelativeYY"
    StatsBarBackground.Position = UDim2.new(0.5,0,1.65,0)
    StatsBarBackground.BackgroundTransparency = 1
    StatsBarBackground.Image = "rbxassetid://132724931"
    StatsBarBackground.Parent = BottomFrame

    --Create the health bar.
    local HealthBarBackground = Instance.new("ImageLabel")
    HealthBarBackground.BackgroundTransparency = 1
    HealthBarBackground.Size = UDim2.new(512/1024,0,16/256)
    HealthBarBackground.Position = UDim2.new(0.141,0,0.145,0)
    HealthBarBackground.Image = "rbxassetid://132725297"
    HealthBarBackground.Parent = StatsBarBackground

    local HealthBarFill = Instance.new("ImageLabel")
    HealthBarFill.BackgroundTransparency = 1
    HealthBarFill.Size = UDim2.new(1,0,1,0)
    HealthBarFill.Image = "rbxassetid://132725332"
    HealthBarFill.Parent = HealthBarBackground
    self.HealthBarFill = HealthBarFill

    local HealthText = Instance.new("TextLabel")
    HealthText.BackgroundTransparency = 1
    HealthText.Size = UDim2.new(1,0,1.5,0)
    HealthText.Position = UDim2.new(0.08,0,-0.4,0)
    HealthText.Text = "100/100"
    HealthText.Font = Enum.Font.Antique
    HealthText.TextColor3 = Color3.new(238/255,205/255,255/255)
    HealthText.TextScaled = true
    HealthText.Parent = HealthBarBackground
    self.HealthText = HealthText

    Players.LocalPlayer.CharacterAdded:Connect(function()
        self:ConnectHealthBar()
    end)
    coroutine.wrap(function()
        self:ConnectHealthBar()
    end)()

    --Create the energy bar.
    local EnergyValue = Players.LocalPlayer:WaitForChild("Energy")
    self.EnergyValue = EnergyValue
    local EnergyBarBackground = Instance.new("ImageLabel")
    EnergyBarBackground.BackgroundTransparency = 1
    EnergyBarBackground.Size = UDim2.new(512/1024,0,16/256)
    EnergyBarBackground.Position = UDim2.new(0.141,0,0.225,0)
    EnergyBarBackground.Image = "rbxassetid://132725297"
    EnergyBarBackground.Parent = StatsBarBackground

    local EnergyBarFill = Instance.new("ImageLabel")
    EnergyBarFill.BackgroundTransparency = 1
    EnergyBarFill.Size = UDim2.new(EnergyValue.Value/100,0,1,0)
    EnergyBarFill.Image = "rbxassetid://132725076"
    EnergyBarFill.Parent = EnergyBarBackground

    local EnergyText = Instance.new("TextLabel")
    EnergyText.BackgroundTransparency = 1
    EnergyText.Size = UDim2.new(1,0,1.5,0)
    EnergyText.Position = UDim2.new(0.08,0,-0.4,0)
    EnergyText.Text = tostring(EnergyValue.Value).."/100"
    EnergyText.Font = Enum.Font.Antique
    EnergyText.TextColor3 = Color3.new(238/255,205/255,255/255)
    EnergyText.TextScaled = true
    EnergyText.Parent = EnergyBarBackground

    EnergyValue.Changed:Connect(function()
        EnergyBarFill:TweenSize(UDim2.new(EnergyValue.Value/100,0,1,0),"InOut","Quad",0.1,true)
        EnergyText.Text = tostring(EnergyValue.Value).."/100"
    end)

    --Create the experience bar.
    local PlayerLevels = Levels.GetLevels(Players.LocalPlayer)
    local ExperienceBarBackground = Instance.new("ImageLabel")
    ExperienceBarBackground.BackgroundTransparency = 1
    ExperienceBarBackground.Size = UDim2.new(512/1024,0,16/256)
    ExperienceBarBackground.Position = UDim2.new(0.062,0,0.5 + (3/256),0)
    ExperienceBarBackground.Image = "rbxassetid://132725125"
    ExperienceBarBackground.Parent = StatsBarBackground

    local ExperienceBarFill = Instance.new("ImageLabel")
    ExperienceBarFill.BackgroundTransparency = 1
    ExperienceBarFill.Size = UDim2.new((PlayerLevels.TotalExperience - PlayerLevels.PreviousLevelExperience)/(PlayerLevels.NextLevelExperience - PlayerLevels.PreviousLevelExperience),0,1,0)
    ExperienceBarFill.Image = "rbxassetid://132725249"
    ExperienceBarFill.Parent = ExperienceBarBackground

    local ExperienceBarMarkings = Instance.new("ImageLabel")
    ExperienceBarMarkings.BackgroundTransparency = 1
    ExperienceBarMarkings.Size = UDim2.new(1,0,1,0)
    ExperienceBarMarkings.Image = "rbxassetid://132725193"
    ExperienceBarMarkings.Parent = ExperienceBarBackground

    local ExperienceBarText = Instance.new("ImageLabel")
    ExperienceBarText.BackgroundTransparency = 1
    ExperienceBarText.Position = UDim2.new(0.01,0,0.25,0)
    ExperienceBarText.Size = UDim2.new(32/512,0,8/16,0)
    ExperienceBarText.Image = "rbxassetid://132725160"
    ExperienceBarText.Parent = ExperienceBarBackground

    PlayerLevels.Changed:Connect(function()
        ExperienceBarFill:TweenSize(UDim2.new((PlayerLevels.TotalExperience - PlayerLevels.PreviousLevelExperience)/(PlayerLevels.NextLevelExperience - PlayerLevels.PreviousLevelExperience),0,1,0),"InOut","Quad",0.5,true)
    end)

    --Create the attacks bar.
    self.SelectedAttack = 1
    local AttackButtonsContainer = Instance.new("Frame")
    AttackButtonsContainer.BackgroundTransparency = 1
    AttackButtonsContainer.Size = UDim2.new(390/1024,0,42/256,0)
    AttackButtonsContainer.Position = UDim2.new(82/1024,0,78/256,0)
    AttackButtonsContainer.Visible = false
    AttackButtonsContainer.Parent = StatsBarBackground
    self.AttackButtonsContainer = AttackButtonsContainer

    local AttackSelector = Instance.new("ImageLabel")
    AttackSelector.BackgroundTransparency = 1
    AttackSelector.Size = UDim2.new(46/390,0,46/42,0)
    AttackSelector.Position = UDim2.new(-2/390,0,-2/42,0)
    AttackSelector.ZIndex = 3
    AttackSelector.Image = "rbxassetid://133251112"
    AttackSelector.Parent = AttackButtonsContainer
    self.AttackSelector = AttackSelector
    
    local LastX,LastY = 0,0
    self.AttackButtons = {}
    self.AttackDB = true
    for i,AttackData in pairs(Attacks) do
        --Create the attack button.
        local AttackButton = Instance.new("ImageButton")
        AttackButton.BackgroundTransparency = 1
        AttackButton.Size = UDim2.new(42/390,0,42/42,0)
        AttackButton.Position = UDim2.new((i - 1) * (50/390),0,0,0)
        AttackButton.Visible = (PlayerLevels.Level >= (AttackData.RequiredLevel or 0))
        AttackButton.Image = "rbxassetid://"..tostring(AttackData.Icon)
        AttackButton.Parent = AttackButtonsContainer
        self.AttackButtons[i] = AttackButton

        PlayerLevels:GetPropertyChangedSignal("Level"):Connect(function()
            AttackButton.Visible = (PlayerLevels.Level >= (AttackData.RequiredLevel or 0))
        end)

        EnergyValue.Changed:Connect(function()
            if EnergyValue.Value >= (AttackData.EnergyPerUse or 0) then
                AttackButton.ImageColor3 = Color3.new(1,1,1)
            else
                AttackButton.ImageColor3 = Color3.new(0.5,0.5,0.5)
            end
        end)

        --Connect the button.
        local DB = true
        AttackButton.MouseButton1Down:Connect(function()
            if DB and AttackButtonsContainer.Visible and AttackButton.Visible then
                DB = false
                self:SelectWeapon(i)
                wait()
                DB = true
            end
        end)

        UserInputService.InputBegan:Connect(function(Input,Processed)
            if Processed then return end
            if not AttackButtonsContainer.Visible or not AttackButton.Visible then return end
            if UserInputService:GetFocusedTextBox() then return end
            for _,KeyCode in pairs(AttackData.ActivationKeys or {}) do
                if KeyCode == Input.KeyCode then
                    self:SelectWeapon(i)
                    self:ActivateWeapon(LastX,LastY)
                    break
                end
            end
        end)
    end

    --Connect invoking attacks.
    UserInputService.InputBegan:Connect(function(Input,Processed)
        if Processed then return end
        if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
            self:ActivateWeapon(Input.Position.X,Input.Position.Y)
        end
    end)
    UserInputService.InputChanged:Connect(function(Input)
        if Input.UserInputType == Enum.UserInputType.MouseMovement or Input.UserInputType == Enum.UserInputType.Touch then
            LastX,LastY = Input.Position.X,Input.Position.Y
        end
    end)

    --Connect showing and hiding the attacks.
    StartDungeon.OnClientEvent:Connect(function(_,_,_,Type)
        if Type == "Monster" or Type == "Bloxhilda" then
            AttackButtonsContainer.Visible = true
        end
    end)
    
    EndDungeon.OnClientEvent:Connect(function()
        AttackButtonsContainer.Visible = false
    end)
end

--[[
Connects the health bar for a new character.
--]]
function CenterStats:ConnectHealthBar()
    local Character = Players.LocalPlayer.Character
    if Character then
        local Humanoid = Character:WaitForChild("Humanoid")

        --Connect changes to the health.
        Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
            self.HealthBarFill.Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth,0,1,0)
            self.HealthText.Text = tostring(math.floor(Humanoid.Health + 0.5)).."/"..tostring(math.floor(Humanoid.MaxHealth + 0.5))
        end)
        Humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(function()
            self.HealthBarFill.Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth,0,1,0)
            self.HealthText.Text = tostring(math.floor(Humanoid.Health + 0.5)).."/"..tostring(math.floor(Humanoid.MaxHealth + 0.5))
        end)

        --Set up the current bar.
        self.HealthBarFill.Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth,0,1,0)
        self.HealthText.Text = tostring(math.floor(Humanoid.Health + 0.5)).."/"..tostring(math.floor(Humanoid.MaxHealth + 0.5))
    end
end

--[[
Selects a weapon to use.
--]]
function CenterStats:SelectWeapon(Id)
    self.SelectedAttack = Id
    self.AttackSelector.Position = UDim2.new(((50 * (Id - 1))-2)/390,0,-2/42,0)
end

--[[
Activates the selected weapon.
--]]
function CenterStats:ActivateWeapon(X,Y)
    --Return if the attack if unusable.
    if not self.AttackButtonsContainer.Visible then return end
    if not self.AttackButtons[self.SelectedAttack].Visible then return end
    if self.AttackButtons[self.SelectedAttack].ImageColor3 ~= Color3.new(1,1,1) then return end

    --Return if the attack is in progress.
    if not self.AttackDB then return end
    self.AttackDB = false

    --Determine the target.
    local Camera = Workspace.CurrentCamera
    local CameraMouseRay = Camera:ScreenPointToRay(X,Y,10000)
    local TargetEndPos = CameraMouseRay.Origin + CameraMouseRay.Direction
    local CharacterIgnoreList = RaycastParams.new()
    CharacterIgnoreList.FilterType = Enum.RaycastFilterType.Blacklist
    CharacterIgnoreList.FilterDescendantsInstances = {Players.LocalPlayer.Character}
    local RaycastResults = Workspace:Raycast(Camera.CFrame.Position,TargetEndPos - Camera.CFrame.Position,CharacterIgnoreList)

    --Activate the attack.
    local AttackData = Attacks[self.SelectedAttack]
    local AttackClass = ReplicatedStorageProject:GetResource("State.Tool.Attack."..AttackData.Name)
    if RaycastResults then
        if AttackClass.PerformClientAttack then
            AttackClass.PerformClientAttack(RaycastResults.Position)
        end
        PerformAttack:FireServer(self.SelectedAttack,RaycastResults.Position)
    else
        if AttackClass.PerformClientAttack then
            AttackClass.PerformClientAttack(TargetEndPos)
        end
        PerformAttack:FireServer(self.SelectedAttack,TargetEndPos)
    end

    --End attack.
    wait(AttackData.AttackCooldown or 0)
    self.AttackDB = true
end



return CenterStats