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: Health system in a building. (Problem)

Previous Thread :: Next Thread 
MasterOvMinds is not online. MasterOvMinds
Joined: 26 Sep 2008
Total Posts: 127
26 Jun 2016 05:57 AM
I am trying to implement a simple system in which a specific model or building holds a value which determines how many times it can be hit by a specific projectile (In this case "Rock") before activating a destruction script.
So far I have had trouble getting a script to subtract the "health" value as soon as a projectile (Rock) hits the block the script and value it is inside in.
The script looks like this:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local health = script.Parent.Health.Value

function onTouched(part)
local h = part.Parent:findFirstChild("Rock")
if h~=nil then
wait()
health = health - 1
end
end


script.Parent.Touched:connect(onTouched)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When tested the value appeared unchanged. When this failed I tried this to check out if a value can indeed be subtracted:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local health = script.Parent.Health.Value

while true do
wait(1)
heath = health - 1
print(health)
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The output shows that the subtraction is working.
So I have a question. Why cant a simple value to be subtracted as soon as an object hits the trigger? Am I doing something wrong?
Report Abuse
MasterOvMinds is not online. MasterOvMinds
Joined: 26 Sep 2008
Total Posts: 127
26 Jun 2016 06:29 AM
Also you can take a look at this for some context to what am I doing:

http://www.roblox.com/games/13093174/Pompeii-destruction-test
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