4주차>
👨🏫 toolbox → flag stand 검색 → 두 개 배치하기
👨🏫 toolbox → drooling zombie 검색 → 한 개 배치하기
👨🏫 drooling zombie Script 들어가기 → 내용 모두 지우기 → 이름: DroolingZombie
👨🏫 DroolingZombie code
local zombie = game.Workspace["Drooling Zombie"]
local humanoid = zombie.Humanoid
local pointA = game.Workspace.①
local pointB = game.Workspace.②
local nextpoint = ③
local DELAY = ④
while ⑤ do
humanoid:⑥(nextpoint.PrimaryPart.⑦)
humanoid.⑧:⑨()
if ⑩ then
ⓐ
else
ⓑ
end
end
👨🏫 toolbox → npc → Walking and 클릭
👨🏫 Walking Script와 NPC chat script 코드 보면서 수업 때 배운 부분만 이해하고 code 일부 바꿔보기 → npc가 어떻게 행동하는 지 바뀐 행동 관찰해보기!
👨🏫 Walking Script code
local CurrentPart = nil
local MaxInc = 16
function onTouched(hit)
if hit.Parent == nil then
return
end
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid == nil then
CurrentPart = hit
end
end
function waitForChild(parent, childName)
local child = parent:findFirstChild(childName)
if child then
return child
end
while true do
print(childName)
child = parent.ChildAdded:wait()
if child.Name==childName then
return child
end
end
end
local Figure = script.Parent
local Humanoid = waitForChild(Figure, "Humanoid")
local Torso = waitForChild(Figure, "Torso")
local Left = waitForChild(Figure, "Left Leg")
local Right = waitForChild(Figure, "Right Leg")
Humanoid.Jump = true
Left.Touched:connect(onTouched)
Right.Touched:connect(onTouched)
while true do
wait(math.random(0.001, 3))
if CurrentPart ~= nil then
if math.random(1, 2) == 1 then
Humanoid.Jump = true
end
Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart)
end
end
👨🏫 NPC chat script
local head = script.Parent
local randomChats = {
"I may struggle with geography, but I'm sure I'm somewhere around here.",
"The baby in the sun from teletubbies is 24 years old now.",
"If you ever feel bad about your looks just remember that shrek was inspired by a real life human being",
"Bingo is like battle royale for the elderly.",
"Somebody once told me the world is gonna roll me.",
}
while true do
wait(math.random(15, 30))
local last
local r = randomChats[math.random(1, #randomChats)]
if not(r == last) then
game:GetService("Chat"):Chat(head, r, "Blue")
end
end
-- Put this in the Head of the NPC that you want to talk.
'Roblox Game Creator' 카테고리의 다른 글
로블록스_심화_6주차 (Items 2/2) (0) | 2023.01.12 |
---|---|
로블록스_심화_5주차 (Items 1/2) (0) | 2022.12.29 |
로블록스_심화_3주차 (NPC 1/2) (0) | 2022.12.15 |
로블록스_심화_2주차(Animation) (0) | 2022.12.07 |
로블록스_심화_1주차(Magic Staircase) (0) | 2022.11.29 |
댓글