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

Why doesn't my damage increase when Combat Value increases?!?

Asked by 8 years ago

basically when your attk increases your dmg is supposed to increase and do more damage to an enemyhumanoid why isn't this working?

01wait(2)
02 
03Player = game.Players.LocalPlayer
04P = script.Parent:WaitForChild("Animation")
05char =Player.Character
06RA = char["Left Arm"]
07k = 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
12function  onDamage(Part)
13    if k == true then
14        k = false
15        if script.Parent.Punch.Value == 4 then
View all 25 lines...

2 answers

Log in to vote
0
Answered by 8 years ago

Explanation in chat.

01wait(2)
02 
03Player = game.Players.LocalPlayer
04P = script.Parent:WaitForChild("Animation")
05char =Player.Character
06RA = char["Left Arm"]
07k = true
08 
09local attk = script.Parent.Parent.Combat
10local def = script.Parent.Parent.Defense
11 
12function 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
View all 29 lines...

Hope this helps, comment if you need any help.

Ad
Log in to vote
0
Answered by 8 years ago

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,

01wait(2)
02 
03Player = game.Players.LocalPlayer
04P = script.Parent:WaitForChild("Animation")
05char =Player.Character
06RA = char["Left Arm"]
07k = true
08 
09 
10function  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
View all 29 lines...

Answer this question