동전 더미
Coddy의 Roblox 게임: 펫 시뮬레이터 코스 레슨. 18개 중 2번째.
코인은 더미에서 나옵니다. Meadow에는 더미를 놓을 자리가 8곳 있으며, 이 자리는 workspace.Zones.Meadow.Spawns에 있는 보이지 않는 파트입니다. ServerStorage.CoinPile은 더미 자체로, 플레이어가 절대 볼 수 없는 곳에서 기다리고 있습니다.
자리에 더미를 놓으려면 템플릿을 복제한 다음 복사본을 그곳으로 옮기세요. 각 더미는 자신의 체력과 가치를 기억해야 합니다. 속성을 사용하면 인스턴스 자체에 이런 값을 저장할 수 있습니다.
pile:SetAttribute("Health", 3)
print(pile:GetAttribute("Health")) --> 3복사본마다 자체 속성을 가지므로, 더미마다 체력이 따로 있습니다.
챌린지
쉬움- 상단 근처에:
local ServerStorage = game:GetService("ServerStorage")와local piles = workspace.Piles. spawnPile(spot)을 작성하세요.ServerStorage.CoinPile을 복제하고, 해당 지점의 Position에 배치한 다음,MaxHealth와Health속성을Settings.PileHealth로,Value속성을Settings.PileValue로 설정하세요.piles를 부모로 지정하고 반환하세요.workspace.Zones.Meadow.Spawns의 모든 지점에 대해 호출하세요.
Play를 누르세요. 잔디 위에 금 더미가 나타납니다. 그런 다음 Check를 누르세요.
직접 해보기
local Players = game:GetService("Players")
local Settings = require(game.ReplicatedStorage.Settings)
print("A Meadow pile gives " .. Settings.PileValue .. " coins")
-- 모든 플레이어는 리더보드에 Coins를 받습니다
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats
end)
이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.