basically when your attk increases your dmg is supposed to increase and do more damage to an enemyhumanoid why isn't this working?
01 | wait( 2 ) |
02 |
03 | Player = game.Players.LocalPlayer |
04 | P = script.Parent:WaitForChild( "Animation" ) |
05 | char = Player.Character |
06 | RA = char [ "Left Arm" ] |
07 | k = true |
08 | local attk = script.Parent.Parent.Combat.Value |
09 | local def = script.Parent.Parent.Defense.Value |
10 | local d = (attk/def)* 10 + 1 |
11 | local dmg = d/def |
12 | function onDamage(Part) |
13 | if k = = true then |
14 | k = false |
15 | if script.Parent.Punch.Value = = 4 then |
Explanation in chat.
01 | wait( 2 ) |
02 |
03 | Player = game.Players.LocalPlayer |
04 | P = script.Parent:WaitForChild( "Animation" ) |
05 | char = Player.Character |
06 | RA = char [ "Left Arm" ] |
07 | k = true |
08 |
09 | local attk = script.Parent.Parent.Combat |
10 | local def = script.Parent.Parent.Defense |
11 |
12 | function onDamage(Part) |
13 | if k then -- we dont need to check for true as it will only run if true |
14 | k = false |
15 | if script.Parent.Punch.Value = = 4 then |
Hope this helps, comment if you need any help.
The reason your damage isn't updating is because you only set its value ONCE in your current script (at line 11). To make sure the damage value changes, you need to set it INSIDE your function. so,
01 | wait( 2 ) |
02 |
03 | Player = game.Players.LocalPlayer |
04 | P = script.Parent:WaitForChild( "Animation" ) |
05 | char = Player.Character |
06 | RA = char [ "Left Arm" ] |
07 | k = true |
08 |
09 |
10 | function onDamage(Part) |
11 | if k = = true then |
12 |
13 | local attk = script.Parent.Parent.Combat.Value |
14 | local def = script.Parent.Parent.Defense.Value |
15 | local d = (attk/def)* 10 + 1 |