How do I create a part that when it's touched, your jump height changes

So I’m trying to change the jump height of a player after they touch a part in the workspace.

Right now, the script isn’t doing anything in changing the jump height of a player.

I’ve tried looking through a few posts, and none of them work. I tried using a script that did something else that changed the walkspeed of a player, but changing that didn’t work so I’m struggling to make it work.

local player = game:GetService("StarterPlayer")
local part = script.Parent

local function onTouch(jump)
	local humanoid = jump.Parent:FindFirstChild('Humanoid')
	if humanoid then
		player.CharacterJumpHeight = 10
	end
end

part.Touched:Connect(onTouch)
1 Like

I think it should be player.Character.Humanoid.JumpHeight = 10
Also you can’t define the player as that.

Try this

local part = script.Parent

local function onTouch(hit)
	if hit and hit.Parent then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player then
			player.Character.Humanoid.JumpHeight = 10
		end
	end
end

part.Touched:Connect(onTouch)
5 Likes

You should use JumpPower

local part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.JumpPower = 100 -- Set the number to the desired jump power
	end
end)
4 Likes

I think he would have to change it in the game’s settings to use jump power instead of jump height.

1 Like

In that case, the solution I provided should still work as long as you replace JumpPower with JumpHeight.

local part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.JumpHeight = 100 -- Set the number to the desired jump height
	end
end)

Tested your solution too, which works as well.

3 Likes