Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Don't My Attacks Work?

Asked by 3 years ago
Edited 3 years ago

I'm working on a fighting game and i'm tryna code attacks, for some reason, the attack doesn't deal any damage,

ATK1 (LocalScript)

local ContextActionService = game:GetService("ContextActionService")
local plr = game.Players.LocalPlayer
local function ATK1(actionName, inputState, inputObject)
    if plr.Team == game.Teams.Lobby then
        print("not attacking :D")
    else
    if inputState == Enum.UserInputState.Begin then
        if plr.ATK1.Value == 1 then
            local A = Instance.new("Animation", plr.Character)
            A.AnimationId = "rbxassetid://5702590570" --Replace 000 with the numbers at the end of the link to your animation.
            local track = plr.Character.Humanoid:LoadAnimation(A)
            track:Play()
            local hit = plr.WeakHitbox:Clone()
            hit.Parent = plr.Character["Left Arm"]
            plr.Character.Humanoid:UnequipTools()
            wait(0.3)
            hit:Destroy()
        end
        if plr.ATK1.Value == 2 then
            local A = Instance.new("Animation", plr.Character)
            A.AnimationId = "rbxassetid://5709400160" --Replace 000 with the numbers at the end of the link to your animation.
            local track = plr.Character.Humanoid:LoadAnimation(A)
            track:Play()
            local hit = plr.WeakHitbox:Clone()
            hit.Parent = plr.Character["Left Arm"]
            plr.Character.Humanoid:UnequipTools()
            wait(0.3)
            hit:Destroy()
        end
        end
    end
end

ContextActionService:BindAction("ATK1", ATK1, false, Enum.KeyCode.ButtonX, Enum.KeyCode.Z)

varible_insert

local UserInputService = game:GetService("UserInputService")
game.Players.PlayerAdded:connect(function(player) 
    local atk1 = game.ServerStorage.ATK1:Clone()
    local atk2 = game.ServerStorage.ATK2:Clone()
    local atk3 = game.ServerStorage.ATK3:Clone()
    local h1 = game.ServerStorage.NormalHitbox:Clone()
    local h2 = game.ServerStorage.StrongHitbox:Clone()
    local h3 = game.ServerStorage.WeakHitbox:Clone()
    atk3.Parent = player
    atk2.Parent = player
    atk1.Parent = player
    h1.Parent = player
    h2.Parent = player
    h3.Parent = player
end)

attack_give

local UserInputService = game:GetService("UserInputService")
game.Players.PlayerAdded:connect(function(player) 
    player.CharacterAdded:connect(function(char)
        wait(0.5)
        if player.Team == game.Teams.Lobby then
            print("player is in the lobby, and cannot be given items")
        else
            if player.ATK1.Value == 1 then
                local ATK = game.ServerStorage.ATK.Punch:Clone()
                ATK.Parent = player.Backpack
            end
            if player.ATK1.Value == 2 then
                local ATK = game.ServerStorage.ATK["Spin Arm"]:Clone()
                ATK.Parent = player.Backpack
            end
            if player.ATK2.Value == 1 then
                local ATK = game.ServerStorage.ATK.Clap:Clone()
                ATK.Parent = player.Backpack
            end
            if player.ATK3.Value == 1 then
                local ATK = game.ServerStorage.ATK["Throw Head"]:Clone()
                ATK.Parent = player.Backpack
            end
            if player.ATK3.Value == 2 then
                local ATK = game.ServerStorage.ATK["Helicopter"]:Clone()
                ATK.Parent = player.Backpack
            end
        end
    end)
end)

WeakHitbox

script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid:TakeDamage(4)
    end
end)
0
Are there any erorrs? Do you have idea where the problem could be? With that info i will have more chances to find problem in your script. imKirda 4491 — 3y
0
imKirda nope, none. TheEnderG 7 — 3y

Answer this question