Docs / Roblox Games/Destroy It!

Destroy It!

Simulator where players destroy items.

Roblox GamesLuaProfileServiceDestruction PhysicsSimulator
Destroy It!

Overview

Destory it is a game where a player is assigned to their own plot of land. On this plot of land, they are able to spawn in various items that they can blow up and destroy, such as noobs, cars, and so on. When destroying things, players get more and XP to upgrade their base, and have the chance to get better items to destroy.

Key Systems & Features

  • Custom plot system
  • Daily & Timed rewards
  • XP and Level autoscaling
  • Destruction physics

Code Examples

Below are some code snippets from this project.

Detonate Chamber
LUA
local function detonateChamber(player)
	local plotNumber = player:GetAttribute("PlotNumber")
	local equippedChamber = player:FindFirstChild("Data").EquippedChamberEffect.Value
	local plot = workspace.Plots:FindFirstChild("Plot" .. plotNumber)
	if plot then
		local chamber = plot:FindFirstChild("ExplosionChamber")
		if chamber then
			--create explosion info for the explosion simulation
			local ExplosionInfo = {
				Position = chamber:FindFirstChild("ExplosionSpace").CFrame.Position, --always this
				Radius = 8, --get from players current explosion data
				Force = 100
			}
						
			local cashReward, xpReward = game:GetService("ServerScriptService").Gameplay.Scripts.ExplosionScripts[equippedChamber].Detonate:Invoke(player,ExplosionInfo)
			DetonateRemote:FireClient(player)
			
			player:WaitForChild("Data"):WaitForChild("Cash").Value += cashReward
			
			local playerCurrentLevel = player:WaitForChild("Data"):WaitForChild("Level").Value
			local playerCurrentXP = player:WaitForChild("Data"):WaitForChild("XP").Value
			local xpNeeded = LevelCalculator.calculateLevelXP((playerCurrentLevel + 1))
			
			local finalXP = xpReward
			local finalMult = 1
			
			--xp multiplier calculating
			if player:WaitForChild("Data"):WaitForChild("IsInGroup").Value == true then
				finalMult += 0.2
			end
			
			if player:WaitForChild("Data"):WaitForChild("OwnedGamepasses"):WaitForChild("FourTimesXP").Value == true then
				finalMult += 4
			end
			
			finalXP = math.ceil(finalXP * finalMult)
			
			if (playerCurrentXP + finalXP) >= xpNeeded then
				player:WaitForChild("Data"):WaitForChild("XP").Value = 0
				player:WaitForChild("Data"):WaitForChild("Level").Value += 1
				SendNotification:FireClient(player, "You have leveled up!", 4)
			else
				player:WaitForChild("Data"):WaitForChild("XP").Value += finalXP
			end
		end
	end
end

Links