How to disabled player's jump when you hold a tool

hi I’m trying to make a script that disables the players jump when you hold a tool

4 Likes
script.Parent.Touched:Connect(function(NoJump)
local NoJump = NoJump.Parent:FindFirstChild("Humanoid")
if NoJump then
NoJump.JumpPower = 0
end
end)
1 Like

Hi, Should i put this in a LocalScript or a Script?

Put this as a local script under the handle.

1 Like

is this right? Because it doesn’t work for me
image

script.Parent.Equipped:Connect(function()
    local char = script.Parent.Parent

    char.Humanoid.JumpPower = 0
    char.Humanoid.UseJumpPower = true
end)

script.Parent.Unequipped:Connect(function()
    local char = script.Parent.Parent.Parent.Character

    char.Humanoid.JumpPower = 50
    char.Humanoid.UseJumpPower = true
end)
2 Likes
local tool = script.Parent
tool.Equipped:Connect(function()
	local Humanoid = tool.Parent:FindFirstChildWhichIsA("Humanoid")
	if Humanoid then
		Humanoid.JumpPower = 0
	end
end)

insert this into a tool. And paste this code into a server script.

1 Like

I’m a bit late but put this as a server script in the tool. You should give Orbular3 the solution.
tool = script.Parent
function onEquipped()
tool.Parent.Humanoid.JumpPower = 0
end
function onUnequipped()
tool.Parent.Parent.Character.Humanoid.JumpPower = 50
end
tool.Equipped:connect(onEquipped)
tool.Unequipped:connect(onUnequipped)

1 Like

I hope you get the solution since you responded faster than me but you missed one thing, when the tool is unequipped it’s in the player’s backpack and not their character so to find the character it would be script.Parent.Parent.Parent.Character

2 Likes

where do i put it in the localscript or the script?

Make it a script and just put it in the tool, not the handle or anything like that.

1 Like

also it would be handy to keep in mind that in StarterCharacter, You will need to change from using jumpHeight to JumpPower.

Edit: Nevermind I didn’t see that it changes it through the script

i have a bug were you hold the tool it doesn’t let you jump (witch is good) but when i unequip
it still doesn’t let you jump

Did you include @temporaryacount101’s correction? Otherwise it wouldn’t work

ohhh my bad, thank you for helping!

alright, sorry I just had to hop into studio.

If you make a local script inside the tool and paste this in, it should work.

wait(.5)

Player = game.Players.LocalPlayer

Char = Player.Character

script.Parent.Equipped:Connect(function()

Char.Humanoid.UseJumpPower = true

Char.Humanoid.JumpPower = 0

end)

script.Parent.Unequipped:Connect(function()

Char.Humanoid.UseJumpPower = true

Char.Humanoid.JumpPower = 50

end)
2 Likes

although maybe edit the script so that people know the code

1 Like

wow, this script works well thanks alot!

local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()

script.Parent.Equipped:Connect(function()
	character.Humanoid.JumpPower = 0
	character.Humanoid.JumpHeight = 0
end)

script.Parent.Unequipped:Connect(function()
	character.Humanoid.JumpPower = 50
	character.Humanoid.JumpHeight = 7.2
end)

Here’s the correct way to wait for the player and their character, I’ve also declared both as locals as that is considered optimal. I’ve also set both jumping stats to 0 when a tool is equipped, that way exploiters will have a harder time avoiding the “no jump” effect.

1 Like

You could try this:

Script.Parent.Activated:Connect(funcion(plr)
Plr.Humanoid.JumpPower = 0
Else
Plr.Humanoid.JumpPower = 16