I have this script that runs perfectly in studio but doesn’t work at all in game, it doesn’t even print any error in the console.
I don’t have any idea why it does that. Could somone help me ??
RS.Remotes.Event.SellAll.OnServerEvent:Connect(function(player)
local Ores = {
["Rocks"] = 0,
["Diamonds"] = 0,
["Iron"] = 0,
["Gold"] = 0
}
for i, Ore in pairs(player:WaitForChild("PlayerData"):WaitForChild("Ores"):GetChildren()) do
for k, v in pairs(Ores) do
if k == tostring(Ore) then
Ores[tostring(Ore)] = Ore.Value
end
end
end
local Rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
local RocksCoinsGet = Ores["Rocks"] * 2 * Rebirths.Value
local IronCoinsGet = Ores["Iron"] * 7 * Rebirths.Value
local GoldCoinsGet = Ores["Gold"] * 25 * Rebirths.Value
local DiamondsCoinsGet = Ores["Diamonds"] * 100 * Rebirths.Value
local Sum = RocksCoinsGet + DiamondsCoinsGet + IronCoinsGet + GoldCoinsGet
local Coins = player:WaitForChild("leaderstats"):WaitForChild("Coins")
Coins.Value = Coins.Value + Sum
for i, v in pairs(player:WaitForChild("PlayerData"):WaitForChild("Ores"):GetChildren()) do
v.Value = 0
end
end)
RS.Remotes.Event.SellOre.OnServerEvent:Connect(function(player, OreToSell)
local Rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
local Coins = player:WaitForChild("leaderstats"):WaitForChild("Coins")
local Ore = player:WaitForChild("PlayerData"):WaitForChild("Ores"):WaitForChild(OreToSell)
local OreTosellValue = player:WaitForChild("PlayerData"):WaitForChild("Ores")[OreToSell].Value
local Sum = OreTosellValue * RS.Modules.Ores[OreToSell].Value * Rebirths.Value
Ore.Value = 0
Coins.Value = Coins.Value + Sum
end)