Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Parent is nil?

Asked by
KordGamer 155
9 years ago

I'm making a mining script. This script is in a tool and it is a LocalScript.

The error is this:

Local script:69: attempt to index field "Parent" (a nil value)

and this is the part of the script that fails:

01if hitt.Parent.hit.Value < 1 and hitt.Parent.Timber.Value == 0 then --Error here.
02        user.leaderstats.Gold.Value = user.leaderstats.Gold.Value + hitt.Parent.Gold.Value
03        hitt.Parent.Timber.Value = 1
04        wait(resettime)
05    else
06        wait(1)
07    end
08    end
09    ting = 0
10    end
11end

Script Explanation:

The script checks if the hit object is called OreORE. If it is, Then it checks for multiple values, such as Timber and Hit. If the Timber is 0, OreORE is removed and a certain amount of Gold is given to the player.


Any help is appreciated. Thanks!

0
I forgot: It also subtracts 1 from Timber every time it hits the ore. KordGamer 155 — 9y
0
Where is line 69 at? PreciseLogic 271 — 9y
0
@PreciseLogic he commented where the error is. He only posted part of his code, rather than posting the entire thing. Look at line 1 Necrorave 560 — 9y
0
Would be really useful if you gave us a picture of the hierarchy with your question!!!! UserOnly20Characters 890 — 9y
0
Sorry @User, I'll give you it. https://gyazo.com/32c7861e21bf8286734e7c5019a3c1fc KordGamer 155 — 9y

Answer this question