How Do I Make My Combat System Work?
I Trying Making A Combat System And I Can't Seem To Get It To Work
Here Is My Code
001 | local LPunchU = script:WaitForChild( "LPunchU" ) |
002 | local RPunchU = script:WaitForChild( "RPunchU" ) |
004 | local LKickU = script:WaitForChild( "LKickU" ) |
005 | local RKickU = script:WaitForChild( "RKickU" ) |
008 | local char = script.Parent |
010 | local humanoid = char:WaitForChild( "Humanoid" ) |
013 | local uis = game:GetService( "UserInputService" ) |
016 | local debounce = false |
017 | local isAnimationPlaying = false |
021 | local currentAnimationId |
024 | local remoteEvent = game.ReplicatedStorage.OnSuccessfulHit |
027 | uis.InputBegan:Connect( function (input, gameProcessed) |
029 | if gameProcessed or isAnimationPlaying then return end |
032 | if input.KeyCode = = Enum.KeyCode.Q then |
035 | isAnimationPlaying = true |
036 | currentAnimationId = LPunchU.AnimationId |
038 | loadedAnimation = humanoid:LoadAnimation(LPunchU) |
040 | loadedAnimation:Play() |
043 | elseif input.KeyCode = = Enum.KeyCode.E then |
046 | isAnimationPlaying = true |
047 | currentAnimationId = RPunchU.AnimationId |
049 | loadedAnimation = humanoid:LoadAnimation(RPunchU) |
051 | loadedAnimation:Play() |
054 | elseif input.KeyCode = = Enum.KeyCode.F then |
057 | isAnimationPlaying = true |
058 | currentAnimationId = LKickU.AnimationId |
060 | loadedAnimation = humanoid:LoadAnimation(LKickU) |
062 | loadedAnimation:Play() |
065 | elseif input.KeyCode = = Enum.KeyCode.G then |
068 | isAnimationPlaying = true |
069 | currentAnimationId = RKickU.AnimationId |
071 | loadedAnimation = humanoid:LoadAnimation(RKickU) |
073 | loadedAnimation:Play() |
076 | if loadedAnimation then |
079 | loadedAnimation.Stopped:Wait() |
081 | isAnimationPlaying = false |
086 | humanoid.Touched:Connect( function (hit, bodyPart) |
088 | if not isAnimationPlaying or debounce then return end |
090 | local charOfHitPlayer = hit.Parent |
091 | local humanoidOfHitPlayer = charOfHitPlayer:FindFirstChild( "Humanoid" ) |
093 | if not humanoidOfHitPlayer then return end |
098 | if currentAnimationId = = LPunchU.AnimationId and bodyPart.Name = = "LeftHand" then |
100 | remoteEvent:FireServer(humanoidOfHitPlayer) |
102 | elseif currentAnimationId = = RPunchU.AnimationId and bodyPart.Name = = "RightHand" then |
104 | remoteEvent:FireServer(humanoidOfHitPlayer) |
106 | elseif currentAnimationId = = LKickU.AnimationId and bodyPart.Name = = "LeftFoot" then |
108 | remoteEvent:FireServer(humanoidOfHitPlayer) |
110 | elseif currentAnimationId = = RKickU.AnimationId and bodyPart.Name = = "RightFoot" then |
112 | remoteEvent:FireServer(humanoidOfHitPlayer) |
Also I Am Getting This Error
Infinite yield possible on 'Workspace.Proskillez342.Combat Handler:WaitForChild("LKickU")'