How to make Humanoid jump when button is clicked

I am trying to set Humanoid.Jump to true when I click a guibutton, but it doesnt work

can you show a script, or at least the explorer so we may help?

Here

game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
	local hum = char:WaitForChild("Humanoid")
	script.Parent.MouseButton1Click:Connect(function()
		hum.Jump = true
	end)
end)

You might need to use Server side scripts

Yayyy it works now, thank you!

this may be a solution but it generally isn’t a great idea to handle uis with server scripts in case you wanna use stuff like userinputservice or modify the localplayer or something like that

i think humanoid:ChangeState(Enum.HumanoidStateType.Jumping) works too but you need to beware i think it is possible to exploit this. someone might spam click the button to jump to the stratosphere so i recommend doing this:

script.Parent.MouseButton1Click:Connect(function() -- this is a local script
	local plr = game:GetService("Players").LocalPlayer
	local chr = plr.Character or plr.CharacterAdded:Wait()
	local hum = chr:WaitForChild("Humanoid")
	if hum.Material ~= Enum.Material.Air then -- if not midair
		hum:ChangeState(Enum.HumanoidStateType.Jumping) -- you can do hum:ChangeState(3) too
	end
end)

since your gui probably has resetOnSpawn on (it should have resetOnSpawn on in this case imo), this will work.

Oh thank you, the server side made the jump a little late so this is a better solution

ty this also solved my issue so i dont need to do much work

1 Like