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: How would I reference a Value in another Model?

Previous Thread :: Next Thread 
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 12:08 PM
Hello!

Im curious as to how I would reference another value in a model from a part that touches that model?

Im trying to make a ship Damage system and Ive set it up so that if a Part named "Tip" hits that Model then the Value in that hit model minus 2 in the value.

Any idea how I would reference that value in the said model that is hit?
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
24 Dec 2013 12:17 PM
so you have a part that hits a model, and you want the model.Health.Value to decrease?

Tip.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Health") t hen
hit.Parent.Health.Value = hit.Parent.Health.Value-2
end
end)

Like that?
Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 12:18 PM
Ooo, Lemme try that. I had a feeling it was that findfirstchild but I wasent sure.

Thank you!
Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 12:24 PM
Im getting an Error from it. Attempt to indx global "Tip" a nil value.

Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
24 Dec 2013 12:26 PM
where are you putting the script?
Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 12:28 PM
in the Part named "Tip" Its in a model, in a model.

script>Tip>Model>Model
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
24 Dec 2013 12:38 PM
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Health") then
hit.Parent.Health.Value = hit.Parent.Health.Value-2
end
end)


Try that then. This is assuming the value you want to decrease is called Health, and is a number or int value.
Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 12:53 PM
It works in a sense my game didnt lag out but the value in the other model dosent minus either.
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
24 Dec 2013 12:56 PM
Is this the correct hierarchy for the model that is hit:

model
-Health
-Part
-Part
-Part
-Part
-Part
-Part
-Part
-Part



Where Health is a number value, and is named 'Health', and Part is the part that is hit.
Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 01:04 PM
Its Model
Integrity(IntValue)
Helm
Hull
Log
Log
Etc...
Tip
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
24 Dec 2013 01:06 PM
This then:

script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Integrity") then
hit.Parent.Integrity.Value = hit.Parent.Integrity.Value-2
end
end)

Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 01:08 PM
I tried that. Didnt work. I even added

Hull = script.Parent.Parent.Parent

script.Parent.Touched:connect(function(hit)
if hit.Name == "Log" then
if hit.Parent:FindFirstChild("Integrity") then
hit.Parent.Integrity.Value = hit.Parent.Integrity.Value - 1
end
end
end)
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
24 Dec 2013 01:12 PM
Try showing the models like this:

-Model
--Model
---Model
----Part
----Part
----Part
----^Script
----Part
----^Script
-----Model
------Part
-------^Script

Like this, if you see what I mean, you probably showed it wrong and the Parenting is wrong quite much!
Report Abuse
ArtemisFlux is not online. ArtemisFlux
Joined: 15 Sep 2012
Total Posts: 120
24 Dec 2013 01:15 PM
-Model
--IntValue
--Model
--Model
---Log
---Log
---50 Log's Later
---Tip
----^script

should just be

script.Parent.Parent.Parent
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
24 Dec 2013 01:18 PM
integ = hit.Parent.Parent.Parent.Integrity

script.Parent.Touched:connect(function(hit)
if hit.Name == "Log" then
if hit.Parent:FindFirstChild("Integrity") then
integ.Value = integ.Value - 1
end
end
end)
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