完成動画
はじめに
使用する主な機能
手順動画
エクスプローラー構成
実装するにあたっての考え方
スクリプトの内容
local switchPart = script.Parent
local targetBlock = workspace:WaitForChild("Part")
-- 何人が乗っているかを数えるカウンター
local touchingCount = 0
-- Touched: プレイヤーが乗ったとき
switchPart.Touched:Connect(function(hit)
local character = hit.Parent
if character and character:FindFirstChild("Humanoid") then
touchingCount += 1
if touchingCount == 1 then
targetBlock.Transparency = 0
targetBlock.CanCollide = true
end
end
end)
-- TouchEnded: プレイヤーが降りたとき
switchPart.TouchEnded:Connect(function(hit)
local character = hit.Parent
if character and character:FindFirstChild("Humanoid") then
touchingCount -= 1
if touchingCount <= 0 then
touchingCount = 0
targetBlock.Transparency = 1
targetBlock.CanCollide = false
end
end
end)



コメント