I'm getting the error Players.Player.PlayerGui.ScreenGui.Dollars.TextLabel.Script:39: attempt to index local 'playerData' (a number value) online 39. Why is this?
plr = script.Parent.Parent.Parent.Parent.Parent
dollarstheyhave = 0
notLead = Instance.new('Model', plr)
notLead.Name = 'notleaderstats'
doll = Instance.new('NumberValue', notLead)
doll.Name = 'Dollars'
doll.Value = dollarstheyhave
------------------------------------------------------------------------------------
plr:WaitForChild('notleaderstats').Dollars.Changed:connect(function()
changetext(tostring(plr.notleaderstats.Dollars.Value))
update(plr)
end)
------------------------------------------------------------------------------------
function changetext(msg)
script.Parent.Text = msg
end
ds = game:GetService("DataStoreService"):GetDataStore('Dollars')
function update(player)
local playerIdentity = player.Name .. '(' .. player.userId .. ')' --Makes identity
local playerKey = 'player_' .. player.userId --Makes key
local playerData = ds:GetAsync(playerKey) --gets datastore
for i,v in pairs (ds:GetChildren()) do
print(v)
end
if playerData then
if playerData.Amount <= 0 then --FIX THIS: ERROR SAYS ARGUMENT 2 IS MISSING OR NIL WHICH MEANS WE NEED TO FIX THE playerData.personalPlaceId PART
playerData = nil
end
end
if not playerData then
--ADD TUTORIAL THING
playerData = {
Amount = 10
}
ds:SetAsync(playerKey, playerData)
end
if playerData and playerData.personalPlaceId then
dollarstheyhave = playerData
end
end
