Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Attempt to index local money (a nil value)?

Alright, I've made a datastorage script but it is completely ignoring the value, I understand what the issue is, the value for some reason "doesn't exist" but I dont know how to fix it, Its clear that the **SERVERSCRIPT ** is unable to access it, where else would I put it (i tried in character, but it ignores the value)

btw this error has NOTHING to do with datastorage , any help? (ps the cash is inside StarterPlayerScripts that is then inside PlayerScripts i cant access playerscripts but idk where else to put it)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
saveMoneyEvent = game.ReplicatedStorage.saveMoneyEvent
HttpService = game:GetService("HttpService")

local function onSaveMoneyFired(player, money)
print ("saving...")
player:FindFirstChild('cash').Value = money --issue
local databaseService = require(game.ServerScriptService.DatabaseService)
local globalDatabase = databaseService:GetDatabase("Global")
print (money)  --issue via chain reaction
local frank = HttpService:JSONEncode(money)  --issue via chain reaction
print(frank)  --issue via chain reaction
print(HttpService:JSONDecode(frank))  --issue via chain reaction
globalDatabase:PostAsync(player.Name, frank)  --issue via chain reaction
end


saveMoneyEvent.OnServerEvent:Connect(onSaveMoneyFired)

7 comments

0

im very confused.

0

the money value on line 7 is a nil value (doesnt exist) and its because the script cant access PlayerScripts, im unsure where to put the "cash" value instead

0

what kind of name is ____

0

sorry, forgot to explain what i meant by ____ its just a general thing that im trying to understand about indexes, but the thing that cant be found is "money"

0

Show your localscript please

0

Put the cash in leaderstats. So make a leaderstats folder that you'll place in Player, then insert the cash value into there.

0

i dont want to use leaderstats, i want the money value to not be able to be seen, without disabling the leaderboard gui thing

1 answer

✓ Accepted answer

Remove the line that you have an issue on. In your localscript pass your money ex:

event:FireServer(money.Value)

This discussion is preserved as it was. New answers, comments, and votes are closed.