Why Don't My Attacks Work?
Asked by
4 years ago Edited 4 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)
01 | local ContextActionService = game:GetService( "ContextActionService" ) |
02 | local plr = game.Players.LocalPlayer |
03 | local function ATK 1 (actionName, inputState, inputObject) |
04 | if plr.Team = = game.Teams.Lobby then |
05 | print ( "not attacking :D" ) |
07 | if inputState = = Enum.UserInputState.Begin then |
08 | if plr.ATK 1. Value = = 1 then |
09 | local A = Instance.new( "Animation" , plr.Character) |
11 | local track = plr.Character.Humanoid:LoadAnimation(A) |
13 | local hit = plr.WeakHitbox:Clone() |
14 | hit.Parent = plr.Character [ "Left Arm" ] |
15 | plr.Character.Humanoid:UnequipTools() |
19 | if plr.ATK 1. Value = = 2 then |
20 | local A = Instance.new( "Animation" , plr.Character) |
22 | local track = plr.Character.Humanoid:LoadAnimation(A) |
24 | local hit = plr.WeakHitbox:Clone() |
25 | hit.Parent = plr.Character [ "Left Arm" ] |
26 | plr.Character.Humanoid:UnequipTools() |
34 | ContextActionService:BindAction( "ATK1" , ATK 1 , false , Enum.KeyCode.ButtonX, Enum.KeyCode.Z) |
varible_insert
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | game.Players.PlayerAdded:connect( function (player) |
03 | local atk 1 = game.ServerStorage.ATK 1 :Clone() |
04 | local atk 2 = game.ServerStorage.ATK 2 :Clone() |
05 | local atk 3 = game.ServerStorage.ATK 3 :Clone() |
06 | local h 1 = game.ServerStorage.NormalHitbox:Clone() |
07 | local h 2 = game.ServerStorage.StrongHitbox:Clone() |
08 | local h 3 = game.ServerStorage.WeakHitbox:Clone() |
attack_give
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | game.Players.PlayerAdded:connect( function (player) |
03 | player.CharacterAdded:connect( function (char) |
05 | if player.Team = = game.Teams.Lobby then |
06 | print ( "player is in the lobby, and cannot be given items" ) |
08 | if player.ATK 1. Value = = 1 then |
09 | local ATK = game.ServerStorage.ATK.Punch:Clone() |
10 | ATK.Parent = player.Backpack |
12 | if player.ATK 1. Value = = 2 then |
13 | local ATK = game.ServerStorage.ATK [ "Spin Arm" ] :Clone() |
14 | ATK.Parent = player.Backpack |
16 | if player.ATK 2. Value = = 1 then |
17 | local ATK = game.ServerStorage.ATK.Clap:Clone() |
18 | ATK.Parent = player.Backpack |
20 | if player.ATK 3. Value = = 1 then |
21 | local ATK = game.ServerStorage.ATK [ "Throw Head" ] :Clone() |
22 | ATK.Parent = player.Backpack |
24 | if player.ATK 3. Value = = 2 then |
25 | local ATK = game.ServerStorage.ATK [ "Helicopter" ] :Clone() |
26 | ATK.Parent = player.Backpack |
WeakHitbox
1 | script.Parent.Touched:connect( function (hit) |
2 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) then |
3 | hit.Parent.Humanoid:TakeDamage( 4 ) |