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

Player is not a valid member of datamodel how to fix??

Asked by 5 years ago

****PLAYER IS NOT A VALID MEMBER OF DATAMODEL

local DataStore = game: GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader. Name = "leaderstats" local Cash = Instance.new("IntValue", leader) Cash.Name = "Cash" Cash.Value = ds:GetAsync(player.UserId) or 0 Cash.Changed:connect(function() ds:SetAsync(player.UserId, Cash.Value)

end) 

end)

game.Player.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)

0
`game.Player.PlayerRemoving` --> game.Players.PlayerRemoving Vulkarin 581 — 5y
0
Wondering if this is actually OP's code. OP had taken an alvinbloxx script... :thonk: User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

In your code snippet, you made a spelling mistake.

game.Player.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)

The reason why it says Player is not a valid member of data model is because there's no service called Player. It's Players.

game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)

Also, as a side note unrelated to your issue, you should use :Connect instead of :connect :)

Ad

Answer this question