概要
プログラミング
- Workspaceに新しくPartを追加
- 名前をJumpBallとかにしておく
- Scriptを追加
Script.lua
-- このScriptの親、つまりJumpBallオブジェクトを変数にいれておく
local boostPart = script.Parent
-- ジャンプ力の設定用の定数
local BOOSTED_JUMP_POWER = 125
local function onPartTouch(otherPart)
-- ぶつかってきたPartの親を変数にいれておく
-- 人間の場合、体のどこかのPartがぶつかったら、その親である人間本体のオブジェクトを変数にいれる
local partParent = otherPart.Parent
-- ぶつかってきたものが人間かどうかを判定
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
-- 当たり判定を無効にする
-- ボールにぶつかったら、ボールがころころ転がらないようにするため
boostPart.CanCollide = false
-- あとで必要なので、「現在のジャンプ力」を変数にいれておく
local currentJumpPower = humanoid.JumpPower
-- 「現在のジャンプ力」が、「強化後のジャンプ力」よりも弱ければ、ジャンプ力を強くする
-- 10秒たったら、元のジャンプ力に戻す
if currentJumpPower < BOOSTED_JUMP_POWER then
humanoid.JumpPower = BOOSTED_JUMP_POWER
wait(10)
humanoid.JumpPower = currentJumpPower
end
end
end
-- 何かがぶつかったらonPartTouch関数が発動
boostPart.Touched:Connect(onPartTouch)




