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

Very confused on this error? Attempt To Index Nil With 'Value'

Asked by 4 years ago

20:13:25.447 - Workspace.Tycoon1.CashModule.Button.ClickDetector.CashCollect:5: attempt to index nil with 'Value'

local cash = game.Workspace.Tycoon1.CashModule.Screen.Cash.Value
local button = script.Parent

button.MouseClick:Connect(function(plr)
    plr:WaitForChild('Cash', 2).Value = cash
    cash.Value = 0
end)

1 answer

Log in to vote
1
Answered by
uhi_o 417 Moderation Voter
4 years ago

Heya, so you already defined .Value in the variable and you are defining it again in the MouseClick event. So just change that up and it should get rid of the error.

local cash = game.Workspace.Tycoon1.CashModule.Screen.Cash
local button = script.Parent

button.MouseClick:Connect(function(plr)
    plr:WaitForChild('Cash', 2).Value = cash.Value
    cash.Value = 0
end)

Ad

Answer this question