Randomized Daily Money System for Players in Roblox ( Lua Script )
- Matthew Campbell
- Apr 4, 2023
- 1 min read
-- Made By: Neutrality Entertainment (Group Owner)
-- Define the leaderboard name
local leaderboardName = "Money"
-- Define the function to generate a random amount of money
local function generateRandomMoney()
-- Define the minimum and maximum values for the random factors
local minFactor1 = 1
local maxFactor1 = 10
local minFactor2 = 1
local maxFactor2 = 5
-- Get the current hour of the day
local hourOfDay = tonumber(os.date("%H"))
-- Set the factors based on the hour of the day
local factor1 = math.random(minFactor1, maxFactor1) + hourOfDay
local factor2 = math.random(minFactor2, maxFactor2) + hourOfDay
-- Generate a random amount of money based on the factors
local money = math.random(100, 1000) * (factor1 / factor2)
-- Round the money to two decimal places
money = math.floor(money * 100) / 100
return money
end
-- Define the function to update the player's money on the leaderboard
local function updatePlayerMoney(player)
-- Get the player's leaderboard
local leaderboard = Instance.new("IntValue")
leaderboard.Name = leaderboardName
leaderboard.Parent = player
-- Generate a random amount of money for the player
local money = generateRandomMoney()
-- Update the player's money on the leaderboard
leaderboard.Value = money
end
-- Define the function to run when a player joins the game
local function onPlayerJoined(player)
-- Update the player's money on the leaderboard
updatePlayerMoney(player)
end
-- Connect the onPlayerJoined function to the Players.PlayerAdded event
game.Players.PlayerAdded:Connect(onPlayerJoined)
Comments