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 » Scripting Helpers
Home Search
 

Re: damage value changes

Previous Thread :: Next Thread 
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
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
RobTheHobo is not online. RobTheHobo
Joined: 09 Apr 2013
Total Posts: 1374
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
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
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
RobTheHobo is not online. RobTheHobo
Joined: 09 Apr 2013
Total Posts: 1374
31 May 2013 01:11 AM
Oh
Report Abuse
Lancet13 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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