Player Not Jumping

I have a script that forces the player to jump, basically like a trampoline. It would be better to show the script rather than attempt to explain it.

local debounce = false
local tramp = game.Workspace.Trampoline

tramp.Touched:Connect(function(hit)
    if not debounce then
	    debounce = true
	    local player = hit.Parent
    	local human = player.Humanoid
	    human.JumpPower = 75 --Change JumpPower if you wish
	    human.Jump = true
	    wait(.5)
	    human.JumpPower = 50
	    debounce = false
    end
end)

The script does everything it’s supposed to do, but the player doesn’t jump for some reason. I can’t figure out why. I put this script inside the part that acts like a trampoline, and it forces the player to jump, and does everything else correctly. But when I made it into a LocalScript, put it in StarterCharacterScripts (and StarterPlayerScripts, but I think StarterCharacterScripts is the correct parent), and tried it, and, like I said above, everything works except the human.Jump = true line.

  1. What do you want to achieve? I want to force players to jump in a LocalScript.

  2. What is the issue? The player won’t jump, and I do not know why.

  3. What solutions have you tried so far? I searched for similar posts, but I either couldn’t understand it, or didn’t find my answer.

I want the code to be in a LocalScript because JumpPower is replicated. Any help is appreciated. :slightly_smiling_face:

2 Likes

Well instead you can change the humanoid’s state to Enum.HumanoidStateType.Jumping which would hopefully make it jump.

humanoid:ChangeState(Enum.HumanoidStateType.Jumping)

And exactly as you want this has to be inside of a local script.

1 Like

you have to use hit.Parent.Humanoid, and you have to check if the touched thing has a humanoid:

local debounce = false
local tramp = game.Workspace.Trampoline

tramp.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if not debounce then
	        debounce = true
    	    local player = hit.Parent
        	local human = player.Humanoid
	        human.JumpPower = 75 --Change JumpPower if you wish
    	    human.Jump = true
	        wait(.5)
	        human.JumpPower = 50
	        debounce = false
        end
    end
end)

and make sure it’s a server script

2 Likes

I put this in the trampoline part:

local d = {}

script.Parent.Touched:Connect(function(h)
	local p = h.Parent
	if p:FindFirstChild("Humanoid") then
		if not d[p] then
			d[p] = true
			p.Humanoid.JumpPower = 100
			p.Humanoid.Jump = true
			wait(0.5)
			p.Humanoid.JumpPower = 50
			d[p] = false
		end
	end
end)

and it works. This has lead me to believe that you cannot set Humanoid.Jump from the client.

Edit

Jump is actually not replicated, so it must be a server script.

There may be some reason as to why this is not a good idea, but I have been messing around with obby jump buttons and was having issues getting the humanoid to actually jump…

Edit* This is running on a server script…

Just using humanoid.Jump = true would seem to just be skipped over every time… so what I’ve found to work is to do:

for i = 1, 10 do
     humanoid.Jump = true
     wait(0.01)
end

Maybe there are reasons this is a bad idea or wouldn’t work in some cases, but it seems to have solved my jump problem… even with my double jump setup it isn’t triggering the double jump only the initial as hoped for. Hope this helps someone…

1 Like