|
| 24 Jul 2016 01:35 PM |
i have this script that deals damage to a humanoid called "Enemy" its parent clones it to a part (i assure you that it works fine) i have narrowed it down to one line, but i have no idea how to deal with this can i get some help?
NOTE: damageenergy is numbervalue
heres the script, i indicated which line is broken:
script.Parent.Touched:connect(function(hit) print("touched") if hit and hit.Parent and hit.Parent:FindFirstChild("Enemy") then -- this one print("detected") hit.Parent:FindFirstChild("Enemy").Health = hit.Parent:FindFirstChild("Enemy").Health - game.Lighting:FindFirstChild("DamageEnergy").Value game.Lighting:FindFirstChild("DamageEnergy"):Destroy() script:Destroy() end end) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 24 Jul 2016 08:26 PM |
| one more thing, its working in studio but not in game |
|
|
| Report Abuse |
|
|
|
| 24 Jul 2016 08:27 PM |
| Just use :TakeDamage() u noob |
|
|
| Report Abuse |
|
|
|
| 24 Jul 2016 08:28 PM |
| you're probably using a LocalScript instead of a ServerScript, or Vise Versa, try switching it, that's what happens during this case |
|
|
| Report Abuse |
|
|
|
| 24 Jul 2016 08:45 PM |
Fix:
script.Parent.Touched:connect(function(hit) print("touched") if hit and hit.Parent and hit.Parent:FindFirstChild("Enemy") then -- this one print("detected") hit.Parent:FindFirstChild("Enemy").Health = hit.Parent:FindFirstChild("Enemy").Health - game.Lighting:FindFirstChild("DamageEnergy").Value game.Lighting:FindFirstChild("DamageEnergy"):Destroy() script:Destroy() end end)
game.(what item its touching is in).(name of item):connect(hit)
if that doesn't work then idk.... |
|
|
| Report Abuse |
|
|
|
| 24 Jul 2016 09:18 PM |
Don't use the other one use this one
script.Parent.Touched:connect(function(hit) print("touched") if hit and hit.Parent == hit.Parent:FindFirstChild("Enemy") then -- this one print("detected") hit.Parent:FindFirstChild("Enemy").Health = hit.Parent:FindFirstChild("Enemy").Health - game.Lighting:FindFirstChild("DamageEnergy").Value game.Lighting:FindFirstChild("DamageEnergy"):Destroy() script:Destroy() end end)
game.(what item its touching is in).(name of item):connect(hit) |
|
|
| Report Abuse |
|
|
| |
|