สร้างสะพานอัตโนมัติตามการก้าว


local ladder = script.Parent

local TweenService = game:GetService("TweenService")

ladder.Touched:Connect(function(otherPart: BasePart)
	
	if otherPart.Parent:FindFirstChild("Humanoid") then
		-- โคลนบันไดแล้วปรับตำแหน่งไปด้านหน้า 3 studs วางซ่อนไว้ข้างบน
		local nextLadder = ladder:Clone()
		nextLadder.CFrame *= CFrame.new(0, 50, -3)
		nextLadder.Parent = workspace
		-- ใช้ TweenService เพื่อเล่น Animation โดยให้มันวิ่งมาอยู่ข้างหน้า
		local goal = {}
		goal.CFrame = ladder.CFrame * CFrame.new(0, 0, -3)

		local tween = TweenService:Create(nextLadder, TweenInfo.new(0.5), goal)
		tween:Play()
		-- อย่าลืมลบ Script ทิ้งเพื่อมันจะไม่ทำซ้ำ เหยียบทีเดียวสร้างครั้งเดียว
		ladder.Script:Destroy()
		
	end
end)

ความคิดเห็น