본문 바로가기
Programming/Roblox

로블록스로 배우는 코딩 #9 - 버튼을 눌러 문 열고 닫기

by 강릉바다의 블로그 2022. 10. 6.

lightStatus = false
local light = game.Workspace.Light
local hinge = game.Workspace.Door.HingeConstraint

function onClicked(playerWhoClicked)
	hinge.Enabled = true	
	if not lightStatus then
		light.Color = Color3.fromRGB(255, 255, 0)
		lightStatus = true
		hinge.AngularVelocity = -0.5
		while hinge.CurrentAngle > -90 do
			wait(0.1)
		end
	else
		light.Color = Color3.fromRGB(0, 0, 0)
		lightStatus = false
		hinge.AngularVelocity = 0.5
		while hinge.CurrentAngle < 0 do
			wait(0.1)
		end		
	end
	hinge.Enabled = false
	wait(.1)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

 


강릉바다의 블로그

Since 2008. 1.

https://gnbada.kr/