generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: damage script not working

Previous Thread :: Next Thread 
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
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
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
24 Jul 2016 01:36 PM
What does output say
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
24 Jul 2016 02:00 PM
its clean
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
24 Jul 2016 08:07 PM
b
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
24 Jul 2016 08:26 PM
one more thing, its working in studio but not in game
Report Abuse
epicnesspartan is not online. epicnesspartan
Joined: 29 Jun 2013
Total Posts: 62
24 Jul 2016 08:27 PM
Just use :TakeDamage() u noob
Report Abuse
darkjediwarriorX is not online. darkjediwarriorX
Joined: 26 Aug 2015
Total Posts: 879
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
TypxcalSavage is not online. TypxcalSavage
Joined: 21 Jan 2013
Total Posts: 62
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
TypxcalSavage is not online. TypxcalSavage
Joined: 21 Jan 2013
Total Posts: 62
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
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
26 Jul 2016 06:44 PM
oker

will try
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image