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

Attempt to index a nil value?

Asked by 4 years ago

Im getting an error from this script, any help?

local shirtId = script.Parent.Parent.Coathanger.Shirt.ShirtTemplate

game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player:WaitForChild("leaderstats").Money12.Value>= 1 then -- "If they have money value" local d = character:FindFirstChild("Shirt") d.ShirtTemplate = shirtId end end) end)

0
Why are you checking Money12.Value straight after character is added? You probably want to check if that stat exist (FindFirstChild("Money12")), but still that should not be necessary if you are creating it elswhere... sleazel 1287 — 4y
0
Lua block would help a lot. RunKittenzRComin 170 — 4y
0
why are you defining the shirt using :FindFirstChild, that's not really efficient because if that shirt didnt load yet it might error, but it might've actually loaded so yeah starmaq 1290 — 4y
0
and i think the error is from that if statment, are you sure that an object called Money12 exists and has a Value property? starmaq 1290 — 4y

Answer this question