Add high Jump function when tool pressed?#2

Hi everyone I’m working on an Ability Tool thing and my question is how can I add so the Jump function automatically jumps 2 times higher than normal jump when tool is activated(I hope u guys understand me)

local tool = script.Parent
local savedTime = 0
tool.Activated:Connect(function()
	if os.time() - savedTime >= 10 then
		savedTime = os.time()
	end
end)

What are you using os.time() and savedTime?

local tool = script.Parent
local regularJumpHeight = <your regular jump height here>
local toolJumpHeight = regularJumpHeight * 2

tool.Activated:Connect(function(player)
    local character = player:WaitForChild("Character") or player.CharacterAdded:Wait()
	local humanoid = character.Humanoid
    humanoid.JumpHeight = toolJumpHeight
end)
1 Like

uh.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.JumpPower *= 2

local tool = script.Parent

local cooldown = 10 -- 10 seconds
local currentTime = cooldown

tool.Activated:Connect(function()
    if tick() - currentTime >= cooldown then
        currentTime = tick()
        humanoid.Jump = true
    end
end)
1 Like

I don’t think this will work as when manipulating jump height in a client script, it doesn’t get replicated to the server and other clients.

I thought I saw on a document that you can change humanoid properties with a client script because its owned by the player which is the client.

1 Like

Yes, but as these changes are only client sided, they don’t get replicated to the server, and as such, having something like an anticheat system in place might just think that you’re trying to manipulate your game.

Having all this done in a server script instead eliminates this problem. And it’s basically the same code, with just a few differences as you can see in my provided script.

They do get replicated to the server, and it’s better to do it on the client too because it’s instant feedback. It’s also a lot easier and just works better imo

1 Like

Oh, thanks for telling me that. I was wrong.

I’m not sure about that. Could you please further elaborate on your point here?

1 Like

Easier because when the player inputs the run button (shift) you can just change the jump/speed directly there, instead of having to send a remote event/function to the server and verify bunch of stuff. A lot easier to code and running is smoother with no delay on input

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.