I need the shop to set an object's value, but it will not set the value to said value. Can someone help? I did get an error, but it was not in the line it sets the value in.
He's the error: 21:55:24.796 - ServerScriptService.Leaderboard:50: bad argument #3 (Object expected, got number)
Here's the script:
local dataStoreService = game:GetService("DataStoreService")
local dataStore1 = dataStoreService:GetDataStore("EveryThing")
game.Players.PlayerAdded:Connect(function(player)
local data = Instance.new("Folder",player)
data.Name = "Data"
local level = Instance.new("IntValue",data)
level.Name = "Level"
level.Value = 1
local coins = Instance.new("IntValue",data)
coins.Name = "Coins"
coins.Value = 0
local exp = Instance.new("IntValue", level)
exp.Name = "Exp"
exp.Value = 0
local maxExp = Instance.new("IntValue", level)
maxExp.Name = "Max"
local afk = Instance.new("BoolValue",player)
afk.Name = "afk"
afk.Value = false
local equipped = Instance.new("ObjectValue",player)
equipped.Value = game.ServerStorage:WaitForChild("Frying Pan")
equipped.Name = "Equipped"
local playerUserId = "player: "..player.UserId
local data
local data2
local data3
local data4
local success,errorMessage = pcall(function()
data = dataStore1:GetAsync(playerUserId)
data2 = dataStore1:GetAsync(playerUserId)
data3 = dataStore1:GetAsync(playerUserId)
data4 = dataStore1:GetAsync(playerUserId)
end)
if success then
coins.Value = data
level.Value = data2
exp.Value = data3
equipped.Value = data4
print("Loaded in "..player.Name.." and their stuff.")
else
warn(errorMessage)
end
while wait(0) do
maxExp.Value = 1000 * (1 + player["Data"].Level.Value)
if exp.Value >= maxExp.Value then
level.Value = level.Value + 1
exp.Value = exp.Value - maxExp.Value
end
-- set player's equipped value
for _, toolName in pairs(data4) do
local tool = game.ReplicatedStorage.Tools:FindFirstChild(toolName)
if tool then
equipped.Value = tool
end
end
end
end)

2 comments
why isnt there saving on leave??
I only put in the block where the error was.