pet.OnServerEvent:Connect(function(player, egg)
if game.Workspace.ActualEggs:FindFirstChild(egg) then
local Egg = game.Workspace.ActualEggs:FindFirstChild(egg)
--[[if (Egg.Egg.Position - player.Character.HumanoidRootPart.Position).magnitude >= 15 then
warn("Player is not close enough!")
return;
end]]
local petsThatCanBeWon = require(Modules.EggData)[egg];
local assortedData = {};
local Chances = petsThatCanBeWon.Pets;
local Pull = 0;
local winner = Random.new():NextNumber(1, 100)
local winner2 = nil;
print(winner .. " - " .. typeof(winner))
print(Pull .. " - " .. typeof(Pull))
for petname, chance in pairs(Chances) do
Pull += chance
if winner <= Pull then
winner = petname;
end
end
pet:FireClient(player, egg.Name, winner2);
end
end)
Both pull, and winner is a number. When I do the print’s, it says:
98.69132335165024 - number - Server - Game Controller:176
22:43:04.460 0 - number
It is. The only comparsion in that function atleast, and I matched the lines multiple times.
Also, I removed the mag check to see if it was there and the problem still persist. My eggData module holding the chance value could be the problem. Here that is:
15.955028512877643 - number - Server - Game Controller:176
23:01:37.599 0 - number - Server - Game Controller:177
23:01:37.599 30 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:01:37.599 10 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
ERROR: ServerScriptService.Scripts.Game Controller:181: attempt to compare string <= number - Server - Game Controller:181
95.18894518270578 - number - Server - Game Controller:176
23:07:48.469 0 - number - Server - Game Controller:177
23:07:48.469 30 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:07:48.469 95.18894518270578 - number <- THIS IS THE WINNER FROM THE LOOP - Server - Game Controller:181
23:07:48.469 10 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:07:48.469 95.18894518270578 - number <- THIS IS THE WINNER FROM THE LOOP - Server - Game Controller:181
23:07:48.469 1.13131e-08 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:07:48.469 95.18894518270578 - number <- THIS IS THE WINNER FROM THE LOOP - Server - Game Controller:181
23:07:48.469 1.9999999886869 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:07:48.469 95.18894518270578 - number <- THIS IS THE WINNER FROM THE LOOP - Server - Game Controller:181
23:07:48.469 50 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:07:48.469 95.18894518270578 - number <- THIS IS THE WINNER FROM THE LOOP - Server - Game Controller:181
23:07:48.470 8 - number <- THIS IS THE CHANCE PRINT! - Server - Game Controller:179
23:07:48.470 95.18894518270578 - number <- THIS IS THE WINNER FROM THE LOOP - Server - Game Controller:181
You know what, I just found the issue. I was setting winner to the petname, after it chose a winner, without actually breaking the loop so it would continuing looping and erroring after that.
I’m so sorry for any headache cost. It took a moment to realize that this is the only time it ran through, since it didn’t have to run another loop after it found the winner [since it picked the last index].