Ethan's Portfolio
Ethan Hardie - Roblox Developer

BUILDING EXPERIENCES.
CREATING FUN.

and failing maths

2+
Please accept me colleje sir
Hero Avatar

FEATURED GAMEPLAY SYSTEM EXAMPLES

VIEW ALL SYSTEMS
FEATURED 01 fighting system
Fighting Stike
FIGHTING SYSTEM

Fighting Stike

a character hits another character with a devastating over powered strike

roblox studio lua
3 PLAYS
99 RATING
Script
Lua
--// CombatController.lua
--// Project: Blade Arena
--// Author: Alex

local CombatController = {}

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local RemoteEvents = ReplicatedStorage:WaitForChild("Remotes")
local AttackRemote = RemoteEvents:WaitForChild("Attack")

local COMBO_RESET = 1.25
local ATTACK_COOLDOWN = 0.35
local MAX_COMBO = 4

local ComboData = {}

function CombatController:CanAttack(player)
    local data = ComboData[player]

    if not data then
        ComboData[player] = {
            Combo = 1,
            LastAttack = 0
        }
        data = ComboData[player]
    end

    return tick() - data.LastAttack >= ATTACK_COOLDOWN
end

function CombatController:ProcessAttack(player)

    if not self:CanAttack(player) then
        return
    end

    local data = ComboData[player]

    if tick() - data.LastAttack > COMBO_RESET then
        data.Combo = 1
    else
        data.Combo += 1
    end

    if data.Combo > MAX_COMBO then
        data.Combo = 1
    end

    data.LastAttack = tick()

    local attackInfo = {
        Damage = 12 + (data.Combo * 3),
        Combo = data.Combo,
        Range = 7,
        Knockback = Vector3.new(0,4,12),
        Critical = math.random(1,100) <= 8
    }

    AttackRemote:FireAllClients(player, attackInfo)
end

AttackRemote.OnServerEvent:Connect(function(player)
    CombatController:ProcessAttack(player)
end)

Players.PlayerRemoving:Connect(function(player)
    ComboData[player] = nil
end)

return CombatController

MY FAVORITE GAMES

ABOUT ME

Hey! I'm a Ethan Hardie, a Roblox developer and scripter who loves building fun, polished and unique games. I enjoy turning ideas into playable experiences.

underheart
Zomb