Hey there! I working on a loot box system, and I am getting part of my code from @Alvin_Blox’s video How To Make An EGG HATCHING SYSTEM - Roblox Studio Scripting Tutorial - YouTube
I super recommend all his roblox videos!
and I ran into an issue, I about half way through.
the code in the Module Script
local ItemsModule = {}
ItemsModule.items = {
["Legendary"] = {
"Purple Trail";
};
["Epic"] = {
"Red Trail";
};
["Very Rare"] = {
"Orange Trail";
};
["Rare"] = {
"Yellow Trail";
};
["Uncommon"] = {
"Blue Trail";
};
["Common"] = {
"Green Trail";
};
}
ItemsModule.rarities = {
["Legendary"] = 1;
["Epic"] = 4;
["Very Rare"] = 10;
["Rare"] = 17;
["Uncommon"] = 28;
["Common"] = 40;
}
ItemsModule.chooseRandomItem = function()
local randomNumber = math.random(1,100)
local counter = 0
for rarity, weight in pairs(ItemsModule.rarities) do
counter = counter + weight
if randomNumber <= counter then
local rarityTable = ItemsModule.items[rarity]
local chosenItem = rarityTable[math.random(1, #rarityTable)]
print(chosenItem)
return chosenItem
end
end
end
return ItemsModule
then the client part…
local WAIT = false
local player = game.Players.LocalPlayer
wait(3)
local itemModule = require(game.ServerScriptService:FindFirstChild("ItemsModule"))
function onClick()
if WAIT == false then
print("WaitWorks")
if player.Points.Value >= 500 then
print("Player has enough points")
player.Points.Value = player.Points.Value - 500
WAIT = true
script.ui_count:Play()
--local a = require(game.Players.LocalPlayer:WaitForChild("PlayerGui").Modules.case):create("Classic")
--print(a)
local item = itemModule.chooseRandomItem()
print(item .. "selected")
script.ui_count_complete:Play()
wait(5)
WAIT = false
end
end
end
script.Parent.MouseButton1Down:Connect(onClick)
So I first tried to find the script in the serverscriptservice by doing a waitforchild, but then it had an infinite yield, so I tried findfirstchild, and I got this
I checked and rechecked it but I don’t see what is wrong, maybe a typo or something more elaborate…
Does anyone see something I don’t?