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

Attempt to index local money (a nil value)?

Asked by 5 years ago
Edited 5 years ago

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)

0
im very confused. DinozCreates 1070 — 5y
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 StormcloakGuard 30 — 5y
0
what kind of name is ____ User#24403 69 — 5y
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" StormcloakGuard 30 — 5y
View all comments (3 more)
0
Show your localscript please rokedev 71 — 5y
0
Put the cash in leaderstats. So make a leaderstats folder that you'll place in Player, then insert the cash value into there. TheOnlySmarts 233 — 5y
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 StormcloakGuard 30 — 5y

1 answer

Log in to vote
0
Answered by
Imperialy 149
5 years ago

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

event:FireServer(money.Value)
Ad

Answer this question