01 | script.Parent.Touched:connect( function (hit) |
02 | local h = hit |
03 | local ca = h:FindFirstChild( "Cash" ) |
04 | if ca then |
05 | local civ = script.Parent.Parent.Parent.Parent.Values.InternalCash.Value |
06 | if civ then |
07 | local cav = ca.Value |
08 | civ = civ +cav |
09 | end |
10 | end |
11 | end ) |
No errors occur, but nothing happens.
You had some mistakes, and I explained every single one to the best of my ability.
01 | script.Parent.Touched:connect( function (hit) |
02 | -- no need for local h |
03 | local ca = hit.Parent:findFirstChild( "Cash" ) -- hit is the part that touched, the value is in the character, so you have to do hit.Parent |
04 | if ca then |
05 | local civ = script.Parent.Parent.Parent.Parent.Values.InternalCash -- defining something with ".Value" won't work |
06 | if civ then |
07 | -- no need for local cav, just use ca |
08 | civ.Value = civ.Value + ca.Value |
09 | end |
10 | end |
11 | end ) |
Hope it helps!
As absolute pointed out, line 5 is a problem. But why? Well, when you make a variable equal to a property, no reference to the original object is retained. This means that editing the variable later will not change the property, and if the property changes, the variable will not change with it. The variable will become equal to the value of the property, but it won't actually affect the object.
Therefore, make your variables equal to object. Then you can use the properties, as absolute showed you.