Working on update for my game with a system that connect to the datastore system I have and I keep getting these and it breaks everything
(Repost) (Other scripts if needed ask) Errors
Errors and code (More if you need to have it shown)
Playerdata store
Egg code for collection
–// Variables
local Eggs = workspace.Eggs
local Players = game:GetService(“Players”)
script:WaitForChild(“EggHandler”, 1)
–// Main
for _, egg in ipairs(Eggs:GetChildren()) do
local ProxPrompt = Instance.new(“ProximityPrompt”)
ProxPrompt.Parent = egg
ProxPrompt.ActionText = “Collect”
ProxPrompt.ObjectText = “Trophie”
ProxPrompt.Triggered:Connect(function(player)
player.leaderstats.Wallet.Value += 5000 --Wallet-
if not player.Eggs:FindFirstChild(egg.Name) then
local EggCollected = Instance.new("BoolValue")
EggCollected.Name = egg.Name
EggCollected.Parent = player.Eggs
end
end)
Playerdata code
local DSS = game:GetService(“DataStoreService”)
local statsDS = DSS:GetDataStore(“statsDS”)
game.Players.PlayerAdded:Connect(function(plr)
local lead = Instance.new(“Folder”)
lead.Name = “leaderstats”
lead.Parent = plr
local wallet = Instance.new("IntValue")
wallet.Name = "Wallet"
wallet.Parent = lead
wallet.Value = 55000
local diam = Instance.new("IntValue")
diam.Name = "Bank"
diam.Parent = lead
diam.Value = 0
local Awards = Instance.new("IntValue")
Awards.Name = "Awards"
Awards.Parent = lead
Awards.Value = 0
local data
local succ, err = pcall(function()
data = statsDS:GetAsync(plr.UserId.."-stats")
end)
if succ then
print("success")
if data then --if there was some data then
print("Got the data from the player datastore")
wallet.Value = data[1]
diam.Value = data[2]
Awards.Value = data[3]
end
else
print("There was an error while checking: "..plr.Name)
warn(err)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
print(“Player is leaving the game!”)
local wallet = plr.leaderstats.Wallet.Value
local diam = plr.leaderstats.Bank.Value
local Awards = plr.leaderstats.Awards.Value
print(“Got all the values”)
local data = {wallet, diam, Awards}
local succ, err = pcall(function()
statsDS:SetAsync(plr.UserId.."-stats", data)
end)
if succ then
print("Succesfully saved the data!")
else
print("There was an error while saving player leaderstats!")
warn(err)
end
egg save code
local EggData = game:GetService(“DataStoreService”):GetDataStore(“EggData”)
local OtherEggData = game:GetService(“DataStoreService”):GetDataStore(“OtherEggData”)
game.Players.PlayerAdded:Connect(function(plr)
local Eggs = Instance.new(“Folder”, plr)
Eggs.Name = “Eggs”
local DidEasterEggQuest = Instance.new(“BoolValue”, plr)
DidEasterEggQuest.Name = “DidEasterEggQuest”
DidEasterEggQuest.Value = false
local ClaimedPrize = Instance.new(“BoolValue”, plr)
ClaimedPrize.Name = “ClaimedPrize”
ClaimedPrize.Value = false
local lead = Instance.new(“Folder”, plr)
lead.Name = “leaderstats”
local Data = EggData:GetAsync(plr.UserId)
local Data2 = OtherEggData:GetAsync(plr.UserId)
if Data ~= nil then
for i, v in ipairs(Data) do
local clone = Instance.new("BoolValue")
clone.Name = v
clone.Parent = plr.Eggs
end
end
if Data2 ~= nil then
ClaimedPrize.Value = Data2.ClaimedPrize
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local plrEggs = {}
for i, v in pairs(plr.Eggs:GetChildren()) do
table.insert(plrEggs, v.Name)
end
local dataother = {
ClaimedPrize = plr.ClaimedPrize.Value
}
EggData:SetAsync(plr.UserId, plrEggs)
OtherEggData:SetAsync(plr.UserId, dataother)
end)
Sorry for sounding aggressive, but you know how to format your code properly, right? I can barely read this. (You’re meant to surround all of the code with one pair of ```)
It’s not exactly coding skills we’re talking about here, all you’re doing is copy-pasting text inside a pair of these: ```
They even explain it to you when you write the first post in this thread.
Again, sorry for the aggression, I’m not the best at approaching people.