Robloxでジャンプを無効にする
Robloxでは通常一度ジャンプをすることができるが、JumpPowerを0にすることでジャンプを無効にすることができる
Jumpの初期値を変更する
ExplorerからStarterPlayerを選択、プロパティのCharacterJumpSettingsよりCharacterUserJumpPowerにチェックをいれ、CharacterJumpHeightを0に設定する

結果
ジャンプキーを押してもジャンプしなくなった
※わかりやすさのためジャンプキーを押したときにログを表示している

ローカルスクリプトからジャンプを無効にする
変更したパラメータをデフォルトにもどす

StarterPlayerScripts配下にLocalScriptを作成、名前をDisableJumpに変更する

スクリプトを以下のように編集する
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:wait() local humanoid = character:WaitForChild("Humanoid") humanoid.UseJumpPower = true humanoid.JumpPower = 0
パーツに触れるとジャンプできなくなるようにする
パーツを作成し、配下にスクリプトを作成、名前をDisableJumpに変更する

スクリプトを以下のように編集する
-- パーツを取得 local part = script.Parent -- パーツに触れたときに呼び出される local function onPartTouch(otherPart) -- 触れた対象がプレイヤーだったらジャンプを無効にする local humanoid = otherPart.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.UseJumpPower = true humanoid.JumpPower = 0 end end -- パーツに触れたときのイベントを登録する part.Touched:Connect(onPartTouch)
結果

関連