#how to make this script better

1 messages · Page 1 of 1 (latest)

neat tundra
#

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("ScreenGui")

local BarFrame = gui.BarFrame
local Bar = BarFrame.Bar

local Modules = script.Modules

local Abilities = require(Modules.Abilities)

UIS.InputBegan:Connect(function(i,g)
if g then return end

if i.KeyCode == Abilities.Float.KeyCode then
    Bar.Size = UDim2.new(0,0,1,0)

    Abilities.Use(Bar,"Float")
    
    
end

end)

#
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local HRP = char.HumanoidRootPart

local Abilities = {
    ["Float"] = {
        Usable = true;
        KeyCode = Enum.KeyCode.Q;
        Cooldown = 0
    }
}

local function startCD(Bar : Frame,Ability)
    while task.wait(.1) do
        Ability.Cooldown += .1
        Bar.Size = UDim2.new(Ability.Cooldown,0,1,0)
        print(Ability.Cooldown)

        if Ability.Cooldown >= 5 then
            Ability.Usable = true
            break
        end
    end

end

Abilities.Float.Ability = function (Bar : Frame,Ability)
    if Ability.Usable == false then return end
    local BodyVelocity = Instance.new("BodyVelocity")
    BodyVelocity.Velocity = Vector3.new(0,100,0)
    BodyVelocity.MaxForce = Vector3.new(1e5,1e5,1e5)
    BodyVelocity.P = 5000
    BodyVelocity.Parent = HRP

    task.wait(.1)

    BodyVelocity:Destroy()
    
    Ability.Usable = false
    
    startCD(Bar,Ability)
    
end

function Abilities.Use(Bar : Frame,Name)
    local Check = Abilities[Name]
    if Check then
        Check.Ability(Bar,Check)
    else
        warn("Ability for: ", Name, " not found!")
    end
end

return Abilities
#

yeah I suck at using module scripts

#

😭