キャラクターの大きさを変える
パーツに触れたときにキャラクターを拡大します。
設定とコード例
- Workspace に Part を1つ追加します。
- Part に Script を追加します。
local part = script.Parent
local touch = false
local function onTouched(hit)
local character = hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if not touch and humanoid then
touch = true
local humanoid = character:FindFirstChild("Humanoid")
humanoid.BodyHeightScale.Value *= 1.5 -- 背の高さ
humanoid.BodyDepthScale.Value *= 1.5 -- 体の奥行き
humanoid.BodyWidthScale.Value *= 1.5 -- 体の横幅
humanoid.HeadScale.Value *= 1.5 -- 頭の大きさ
wait(1)
touch = false
end
end
part.Touched:Connect(onTouched)
動作を確かめる
テストで使うアバターのリグや、コードが参照するスケール項目を確認してください。