Skip to content
Roblox

Scripting

Luau scripts for Roblox games: game systems, mechanics and utility code, written to be read and reused.

4.5 out of 515 assets

Mega Dodgeball

6 assetsAdvanced Lua scripting implementation including physics-based ball mechanics, real-time multiplayer synchronization, player progression systems, and comprehensive game state management.
Game page
VideoSettings Menu
0:00 / 0:00
A preview of the settings menu, with toggles and draggable sliders for volume and other settings
VideoMap Picking System
0:00 / 0:00
A preview of the map picking system, with a map list and dynamic avatar display showing the players who voted for each map
VideoEquipment and Customization System
0:00 / 0:00
A video demonstrating the equipment and customization system, with a list of equippable items and the showcase of applied customization by equipping the items
VideoKill & Round Showcase
0:00 / 0:00
A showcase of the kill and round system, showing what happens when a player kills another player and how the final kill triggers the round end
Ball Physics System
local ball = script.Parent -- Ball object
local runService = game:GetService("RunService") -- RunService for time tracking

local function playBounceSound(ballVelocity)
	local speed = ballVelocity.magnitude -- Get the speed of the ball

	-- volume and playback rate based on speed
	local volume = math.clamp(speed / 40, 0, 1) 
	local playbackRate = math.clamp(speed / 50, 0.85, 1.15)

	ball.BallBounce:Play()
	ball.BallBounce.Volume = volume
	ball.BallBounce.PlaybackSpeed = playbackRate

	local currentTime = runService.Stepped:Wait() -- Get the current time
	lastSoundTime = currentTime -- Update the last sound time
end
Dodgeball Physics Based Sound
local tool = script.Parent
local ball = tool.Handle
ball.CanTouch = false

function shootBall(direction)

	tool.Handle.BallBounce:Play()

	local vCharacter = tool.Parent
	local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
	
	local missile:MeshPart = ball:Clone()
	local dangerball = tool.DangerBall
	local spawnPos = vCharacter.PrimaryPart.Position

	spawnPos  = spawnPos + (direction * 5)

	missile.Position = spawnPos
	missile.AssemblyLinearVelocity = direction * 200
	missile.CustomPhysicalProperties = PhysicalProperties.new(
		1.6,			-- Density
		1.55,		 	-- Friction
		0.85			-- Elasticity
	)
	missile.CanCollide = true	
	missile.CanTouch = true
		
	missile.isDangerous.Value = true
	
	dangerball.Enabled = true
	dangerball.Parent = missile
	
	
	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = vPlayer
	creator_tag.Name = "creator"
	creator_tag.Parent = missile
	
	missile.Parent = workspace.Balls
	tool:Destroy()
end

Helliox RNG

5 assetsI developed the core RNG system with exponential luck modifiers, comprehensive inventory and equipment systems, player stats management, and data persistence. This was my first major scripting project where I learned Lua programming through tutorials and practical implementation.
Game page
RNG System Core
return {
	getRandomIndex = function(chances, luckModifier)
		print(luckModifier)
		local totalWeight = 0
		local weightedItems = {}

		-- Calculate weights with an exponential impact of the luck modifier
		for _, item in ipairs(chances) do
			-- Instead of dividing directly, use an exponential adjustment
			local adjustedChance = item.chance ^ (1 / luckModifier)
			local weight = 1 / adjustedChance -- Inverse of the adjusted chance
			table.insert(weightedItems, {item = item, weight = weight})
			totalWeight = totalWeight + weight
		end

		-- Generate a random number within the total weight
		local randomWeight = math.random() * totalWeight

		-- Select the item based on the random weight
		local cumulativeWeight = 0
		for _, weightedItem in ipairs(weightedItems) do
			cumulativeWeight = cumulativeWeight + weightedItem.weight
			if randomWeight <= cumulativeWeight then
				local item = weightedItem.item
				return {name = item.name, chance = item.chance, color = item.color, image = item.image, flavour = item.flavour}
			end
		end
	end
}
Weapon Chances System
local Weapons = game.ReplicatedStorage:WaitForChild("Weapons")

local function isValidated(weapon)

	local requiredChildren = {
		Chance = "IntValue",
		Equipped = "BoolValue",
		ImageID = "StringValue",
		WeaponColor = "Color3Value",
		WeaponDamage = "IntValue",
		WeaponFlavourName = "StringValue"
	}

	for childName, childType in pairs(requiredChildren) do
		local child = weapon:FindFirstChild(childName)
		if not child or not child:IsA(childType) then
			-- If the child is missing or not the correct type, return false
			return false
		end
	end
	return true
end

local weaponChances = {}
for _, weapon in pairs(Weapons:GetChildren()) do
	if isValidated(weapon) then
		table.insert(weaponChances, {
			name = weapon.Name,
			chance = weapon.Chance.Value,
			color = weapon.WeaponColor.Value,
			image = weapon.ImageID.Value,
			flavour = weapon.WeaponFlavourName.Value
		})
	end
end

table.sort(weaponChances, function(a, b)
	return a.chance < b.chance
end)

return weaponChances
Main RNG Controller
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local rngModules = ReplicatedStorage:WaitForChild("RNGModules")
local RemoteEvents = ReplicatedStorage:WaitForChild("Remotes")
local Weapons = ReplicatedStorage:WaitForChild("Weapons")
local chances = require(rngModules.Chances)
local selectChance = require(rngModules.Rng)
local PlayerDataHandler = require(game.ServerScriptService:WaitForChild("PlayerDataHandler"))

local function playerInventoryAdd(player, weapon)
	local rollScore = player.leaderstats.Rolls
	PlayerDataHandler:Update(player, "Rolls", function(currentRolls)
		return currentRolls + 1
	end)
	rollScore.Value = PlayerDataHandler:Get(player, "Rolls")
	
	print(weapon)
	local WeaponStats = Weapons:FindFirstChild(weapon.name)
	local newItem = {
		id = "" .. player.UserId .. "_" .. player.leaderstats.Rolls.Value,
		name = weapon.name,
		chance = weapon.chance,
		color = tostring(WeaponStats.WeaponColor.Value),
		thumbnail = WeaponStats.ImageID.Value,
		damage = WeaponStats.WeaponDamage.Value,
		flavourName = WeaponStats.WeaponFlavourName.Value,
		equipped = false,
		
	}

	PlayerDataHandler:AddToInventory(player, newItem)
end

RemoteEvents.RollDice.OnServerInvoke = (function(player, isInstant)
	local flavorRolls = isInstant and 1 or 10
	local luckModifier = player.PlayerStats.Luck.Value
	print(`Player's Luck: {luckModifier}`)
	local Rolls = {}
	for i = 1, flavorRolls do
		local rollLuckModifier = i < flavorRolls and luckModifier * 100 or luckModifier
		local roll = selectChance.getRandomIndex(chances, rollLuckModifier)
		table.insert(Rolls, roll)
	end
	
	playerInventoryAdd(player, Rolls[flavorRolls])

	RemoteEvents.RollDiceResult:FireClient(player, Rolls)
	return Rolls
end)
VideoLuck Weighting Showcase
0:00 / 0:00
A video showcasing the luck weighting system, where the Player's Luck stat influences the chance of rolling higher rarity weapons, keeping balanced outcomes between lower and higher rarities
VideoAll systems showcase
0:00 / 0:00
A video showcasing all the systems in the game, including the RNG system, inventory system, equipment system, stats system, and rolling system

More

4 assets

UGC Prompt System + Data

1 asset

A system which allows players to earn coins passively and claim UGC items when enough

VideoUGC Prompter
0:00 / 0:00
UGC Prompter

Weighted Wheel of Fate

1 asset

A weighted wheel inspired from "Wheel of Fait"

VideoWeighted Wheel of Fate
0:00 / 0:00
The sections of the wheel are weighted and change size based on the weight dynamically. It's not just a static image.

Simple Dialogue System

2 assets

A simple dialogue system for a "Guide" commission

VideoSimple Dialogue System Showcase
0:00 / 0:00
Simple Dialogue System Showcase
  • How it works