##Problem
Workspace.Land.Model.Detector.Script:6: attempt to index local 'Thirst' (a nil value)?
##Whats wrong
This means that Thirst is nil. You can't index something that is nil since that makes no sense.
###Example code
local a = nil
print(a.b)
This will output an error attempt to index local 'a' (a nil value) since a is nil and not a table or a userdata or has no metatable with a __index set.
##Solution
Think about what your code is doing. You're looking for something called ThirstVal specifically inside plr. Perhaps you have it in a specific folder, or its inside their Character. To index a player's character use the .Character property. (plr.Character)
To prevent this error for now you can check if Thirst even exists in the first place using an if statement.
local clickDetect = ...
local function clicked(player)
print(player)
local thirst = player:FindFirstChild("ThirstVal")
if thirst then
else
warn("no thirst value inside of: " .. player:GetFullName())
end
end
clickDetect.MouseClick:Connect(clicked)
Though again, I do suggest making sure you check where the ThirstVal is actually being added. Perhaps try indexing the player's character and looking for it.
2 comments
it means that ThirstVal is not a child of plr
if ThirstVal isn't a child of plr then it returns nil meaning ur doing nil.Value