StarterPlayerScripts に LocalScript を挿入し、名前を「 二段ジャンプ 」にして、以下のコードを貼り付けましょう。
2段ジャンプできた!!ずっと憧れてた機能が自分で作れるなんて!
StarterPlayerScripts に LocalScript を挿入し、名前を「 二段ジャンプ 」にして、以下のコードを貼り付けましょう。
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local canDoubleJump = false
local UserInputService = game:GetService("UserInputService")
-- キャラクターの状態が変わった時に呼ばれる
humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Freefall then
canDoubleJump = true -- 空中に出たら2段目のジャンプを許可
elseif new == Enum.HumanoidStateType.Landed then
canDoubleJump = false -- 着地したらリセット
end
end)
-- ジャンプボタンが押された時に呼ばれる
UserInputService.JumpRequest:Connect(function()
if canDoubleJump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
canDoubleJump = false
end
end)
2段ジャンプできた!!ずっと憧れてた機能が自分で作れるなんて!
Well done!
次のステップに進みましょう!