|
| 31 May 2013 12:57 AM |
dmg = script.Parent.Damage.Value
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human:TakeDamage(dmg) end end script.Parent.Touched:connect(onTouched)
the dmg on the top changes value but it starts from 2. the script always thinks the dmg is 2 even though it changes from 2-5-10 how do i stop the script from not updating the dmg value? |
|
|
| Report Abuse |
|
|
|
| 31 May 2013 01:03 AM |
I'm not sure so I'm just going to say:
dmg = script.Parent.Damage.Value dmg = 2
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human:TakeDamage(dmg) end end script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 31 May 2013 01:09 AM |
no, the dmg is an int value in the tool. It starts off as number 2 but it changes to other higher numbers The INT value does change numbers but the damage script cant detect it changing so it always damages by 2 |
|
|
| Report Abuse |
|
|
| |
|
Lancet13
|
  |
| Joined: 01 Jun 2008 |
| Total Posts: 34 |
|
|
| 31 May 2013 01:19 AM |
Alright, so I just checked your script and found the issue.
Your script indexes the damage.value before it even runs. Let it index the damage value right before it deals the damage.
In simpler terms
dmg = script.Parent.Damage.Value -- Move this
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then -- Move it here human:TakeDamage(dmg) end end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|