Menu
CoddyTech

금광석

Coddy의 Roblox 게임: 공장 타이쿤 코스 레슨. 18개 중 5번째.

약간의 행운 덕분에 플레이어들은 벨트를 계속 지켜봅니다. 광석 중 일부는 금이며, 가치가 다섯 배입니다. 인수 없이 math.random()을 호출하면 0 이상 1 미만의 숫자가 반환되므로, 열 번 중 한 번은 0.1보다 작습니다.

if math.random() < Settings.GoldChance then
	-- 이건 금이에요
end

금광석은 빛나며(Neon), 가치가 Settings.OreValue * 5입니다. 이 수업의 설정에서는 금이 흔하게 나오므로 많이 볼 수 있습니다.

게임을 진행하는 동안 일부 광석은 벨트에서 떨어집니다. Debris:AddItem(ore, 20)은 각 광석이 어디에 떨어졌든 20초 후에 제거하므로, 월드에 떨어져 나온 부품이 쌓이지 않습니다.

challenge icon

챌린지

쉬움

dropOre에서:

  1. math.random() < Settings.GoldChance이면 광석을 금색으로 만드세요: Color3.fromRGB(255, 200, 40), Neon으로 설정하고 Value를 Settings.OreValue * 5로 설정하세요.
  2. 광석을 부모에 연결한 후, Debris 서비스가 20초 뒤에 제거하도록 하세요.

Play를 눌러 금색 광석이 나오는지 확인한 다음, Check를 누르세요.

직접 해보기

local Players = game:GetService("Players")
local Settings = require(game.ReplicatedStorage.Settings)

local tycoon = workspace.Tycoon

print("Ore is worth " .. Settings.OreValue .. " Cash")

-- 모든 플레이어는 리더보드에서 Cash를 받습니다
Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local cash = Instance.new("IntValue")
	cash.Name = "Cash"
	cash.Parent = leaderstats
end)

-- Ore: 드로퍼 아래에서 떨어지는, Cash 가치가 있는 작은 파트
local function dropOre(dropper)
	local ore = Instance.new("Part")
	ore.Name = "Ore"
	ore.Size = Vector3.new(1, 1, 1)
	ore.Color = Color3.fromRGB(150, 150, 160)
	ore.Position = dropper.Position - Vector3.new(0, 2.5, 0)
	ore:SetAttribute("Value", Settings.OreValue)
	ore.Parent = workspace
end

local function startDropper(dropper)
	task.spawn(function()
		while dropper:IsDescendantOf(workspace) do
			dropOre(dropper)
			task.wait(Settings.DropInterval)
		end
	end)
end

startDropper(tycoon.Dropper)

-- 컨베이어는 그 위에 놓인 모든 것을 운반합니다
tycoon.Conveyor.AssemblyLinearVelocity = Vector3.new(Settings.BeltSpeed, 0, 0)

-- 수집기는 광석을 Cash로 바꿉니다
tycoon.Collector.Touched:Connect(function(hit)
	if hit.Name == "Ore" then
		local value = hit:GetAttribute("Value")
		hit:Destroy()
		for _, player in Players:GetPlayers() do
			player.leaderstats.Cash.Value += value
		end
	end
end)
quiz icon실력 점검

이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.

Roblox 게임: 공장 타이쿤의 모든 레슨