-
What do you want to achieve?
The game should give you the Money you Achieved in the Minigame. -
What is the issue?
It says it’s not valid member of the Player, But I wanted it to be the Value not the Player. -
What solutions have you tried so far?
I did look on the DevHub also I Tried to do
Player:WaitForChild("leaderstats").Cash.Value += CashVal.Value
or
Player:WaitForChild("leaderstats").Cash.Value = Player:WaitForChild("leaderstats").Cash.Value + CashVal.Value
Also here’s the Error Message in the Output:
Here’s the Code for the LocalScript that sends the Value;
Here’s are the Lines of the Code in the ServerScript which makes up the Error;
And If Needed the Whole ServerScript:
local DataStoreService = game:GetService("DataStoreService")
local mps = game:GetService("MarketplaceService")
local DataStore1 = DataStoreService:GetDataStore("DataStore1")
local ProductIDs =
{
[1355625810] = 100,
[1355632905] = 250,
[1355633099] = 500,
[1355633294] = 750,
[1355633541] = 1000,
[1355633896] = 2000,
}
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Chapters = Instance.new("IntValue")
Chapters.Name = "Chapters"
Chapters.Parent = leaderstats
local Blur = Instance.new("IntValue")
Blur.Name = "Blur"
Blur.Parent = leaderstats
local Depth = Instance.new("IntValue")
Depth.Name = "Depth"
Depth.Parent = leaderstats
local Music = Instance.new("IntValue")
Music.Name = "Music"
Music.Parent = leaderstats
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = leaderstats
-- local TrashMission 1 = Quest Active, 2= Not Available for Playthrough robot sad, 0 = Nothing
local PlayerID = "player_"..player.UserId
--Load data
local Data
local Data3
local sucesss, errormessage = pcall(function()
Data = DataStore1:GetAsync(PlayerID)
end)
--Player Get coins
mps.ProcessReceipt = function(purchaseInfo)
local plrPurchased = game.Players:GetPlayerByUserId(purchaseInfo.PlayerId)
if not plrPurchased then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
for productID, coinsGiven in pairs(ProductIDs) do
if purchaseInfo.ProductId == productID then
plrPurchased.leaderstats.Cash.Value = plrPurchased.leaderstats.Cash.Value + coinsGiven
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
--Get coins end
if sucesss then
Cash.Value = Data.Cash
Depth.Value = Data.Depth
Chapters.Value = Data.Chapters
Blur.Value = Data.Blur
Music.Value = Data.Music
end
end)
local player = game
function Save(player)
local PlayerID = "player_"..player.UserId
local data = {
Cash = player.leaderstats.Cash.Value;
Chapters = player.leaderstats.Chapters.Value;
Blur = player.leaderstats.Blur.Value;
Depth = player.leaderstats.Depth.Value;
Music = player.leaderstats.Music.Value;
}
local success, errormessage =pcall(function()
DataStore1:SetAsync(PlayerID, data)
end)
if success then
print("Data saved")
else
print("DataSaving Error")
warn(errormessage)
end
end
local Vals = game.ReplicatedStorage.SavingVals
Vals.OnBlur.OnServerEvent:Connect(function(Player)
Player.leaderstats.Blur.Value = 1
end)
Vals.OffBlur.OnServerEvent:Connect(function(Player)
Player.leaderstats.Blur.Value = 0
end)
Vals.OnDepth.OnServerEvent:Connect(function(Player)
Player.leaderstats.Depth.Value = 1
end)
Vals.OffDepth.OnServerEvent:Connect(function(Player)
Player.leaderstats.Depth.Value = 0
end)
Vals.OnMusic.OnServerEvent:Connect(function(Player)
Player.leaderstats.Music.Value = 1
end)
Vals.OffMusic.OnServerEvent:Connect(function(Player)
Player.leaderstats.Music.Value = 0
end)
Vals.Chapter2.OnServerEvent:Connect(function(Player)
Player.leaderstats.Chapters.Value = 1
end)
Vals.ResetData.OnServerEvent:Connect(function(Player)
Player.leaderstats.Cash.Value = 0
Player.leaderstats.Chapters.Value = 0
end)
Vals.SendRepairMoney.OnServerEvent:Connect(function(Player, CashVal)
wait(1)
Player:WaitForChild("leaderstats").Cash.Value = Player:WaitForChild("leaderstats").Cash.Value + CashVal.Value
end)
game.Players.PlayerRemoving:Connect(Save)
game.ReplicatedStorage.SavingVals.Autosave.OnServerEvent:Connect(Save)