Docs / Roblox Games/+1 Health per RNG
+1 Health per RNG
Simulator where players roll for random health amounts in order to survive obstacles.
Roblox GamesLuaProfileServiceRNGChance AlgorithmsSimulator

Overview
+1 Health per RNG is a game where players click a roll button in order to increase their health value. With this value, players have to go through different obstacles, such as poisonous grass, saws, boulders, and so on. If players pass these area, they can get 'wins' for their venture - which is used to purchase power-ups that are in a pet-like form. These power-ups make the rolls bigger, so players get more health per roll.
Key Systems & Features
- RNG system
- Pet system
- Inventory system
- Product purchase scaling (based on health amount)
Code Examples
Below are some code snippets from this project.
Weighted picking function
LUAlocal function WeightedPick(weightTable)
local total = 0
for _, item in pairs(weightTable) do
total += item.Chance
end
local rand = math.random() * total
local cumulative = 0
for name, item in pairs(weightTable) do
cumulative += item.Chance
if rand <= cumulative then
return name, item
end
end
return "Common", weightTable["Common"]
endOpen chest remote call
LUAOpenChestRemote.OnServerEvent:Connect(function(player, chestName)
local chestData = Chests[chestName]
if not chestData then return end
local playerData = player:FindFirstChild("Data")
if not playerData then return end
if chestData.Currency == "Wins" then
if playerData.Wins.Value >= chestData.Price then
playerData.Wins.Value -= chestData.Price
local rolledItem = ChestRewarding.OpenChest(player, chestName)
if rolledItem then
print("Player rolled:", rolledItem)
ShowRolledItem:FireClient(player, rolledItem)
end
else
local missing = chestData.Price - playerData.Wins.Value
--find smallest win tier >= missing
local closestTier = nil
for winAmount, _ in pairs(WinIDs) do
if winAmount >= missing then
if closestTier == nil or winAmount < closestTier then
closestTier = winAmount
end
end
end
if closestTier then
local id = WinIDs[closestTier]
game:GetService("MarketplaceService"):PromptProductPurchase(player, id)
else
--no tier is large enough, use the largest
local largest = nil
for winAmount, _ in pairs(WinIDs) do
if largest == nil or winAmount > largest then
largest = winAmount
end
end
if largest then
game:GetService("MarketplaceService"):PromptProductPurchase(player, WinIDs[largest])
end
end
end
elseif chestData.Currency == "Robux" then
--prompt purchase
game:GetService("MarketplaceService"):PromptProductPurchase(player, chestData.ID)
end
end)