ジャンプの効果音を追加するscript【Roblox Studio】

Roblox Studioでジャンプした時の音を再生する方法です。

①StarterPlayerScriptsの下にLocalScriptを追加します。LocalScriptのファイル名をJumpSoundScriptとしています。

②JumpSoundScriptの下にSoundを追加します。ファイル名をJumpSoundとしています。

③JumpSoundのSoundIdにIdを入力。音はここでアップロードします。

④JumpSoundScript:

local localPlayer = game.Players.LocalPlayer
local character
local humanoid
local hasJumped
local jumpSound = script.JumpSound


local function characterAdded(newCharacter)
	character = newCharacter
	humanoid = newCharacter:WaitForChild("Humanoid")
	hasJumped = false

	
	humanoid.StateChanged:Connect(function(oldState, newState)

		if newState == Enum.HumanoidStateType.Jumping then

			if hasJumped then return end
			hasJumped = true
			jumpSound:Play()

		elseif newState == Enum.HumanoidStateType.Landed then	

			hasJumped = false

		end
	end)
end

localPlayer.CharacterAdded:connect(characterAdded)

コメントを残す

メールアドレスが公開されることはありません。