Trying to edit jumppower via scripts

I am making like a Jumppower script that refreshes every 5 seconds. The issue I am having is actually editing the jump power, here is the script below.
I tried watching tutorials but most are outdated I also tried looking at a related one about jumppower but that also didn’t work. ANy help would be appreciated. :slight_smile:

local Players = game.Players.LocalPlayer
local Frame = script.Parent.ScreenGui.Jump_Bar.Frame
local Jump = game.StarterPlayer

Players:GetMouse().KeyDown:Connect(function(KeyPressed)
	if KeyPressed == "b" then 
		Frame:TweenSize(UDim2.new(0, 0,0, 14))
		Jump.CharacterJumpPower = 80
		wait(5)
		Frame:TweenSize(UDim2.new(0, 188,0, 14))
		Jump.CharacterJumpPower = 50
	end
end)

Thanks for reading

1 Like

Why don’t you try Players.Character.Humanoid.JumpPower?

2 Likes

Hmm that just messed up everything, this is what I did

local Players = game.Players.LocalPlayer
local Frame = script.Parent.ScreenGui.Jump_Bar.Frame
local Jump = Players.Character.Humanoid

Players:GetMouse().KeyDown:Connect(function(KeyPressed)
	if KeyPressed == "b" then 
		Frame:TweenSize(UDim2.new(0, 0,0, 14))
		Jump.JumpPower = 80
		wait(5)
		Frame:TweenSize(UDim2.new(0, 188,0, 14))
		Jump.JumpPower = 50
	end
end)
1 Like

You should be editing the JumpPower in the Humanoid, not in StarterPlayer.

Also, mouse.KeyDown is deprecated; do not use it in new work. Instead, use UserInputService.

local UserInputService = game:GetService("UserInputService")
local client = game:GetService("Players").LocalPlayer
local powered_up = false

UserInputService.InputBegan:Connect(function(input, engine_processed)
    if engine_processed or input.KeyCode ~= Enum.KeyCode.B then
        return
    end
    

    if powered_up then
        client.Character.Humanoid.JumpPower = 80
        wait(5)
        client.Character.Humanoid.JumpPower = 50
    end 
end
3 Likes

What do you mean by “messed up”? Could you detail what you faced?

1 Like

where shall I put the script, because the one I was using was in startergui

1 Like

It can works in the same place.

1 Like

What if you use “UserInputService” like what @incapaxx did.
and use this in a local script in “StarterCharacter” or “StarterGui”

like

local userInputService = game:getService("UserInputService")
local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid
debounce = false


userInputService.InputBegan:Connect(function(input, isTyping)
      if input.KeyCode == Enum.KeyCode.B then
            debounce = true
            -- Your function here
             wait("Example number")
      end
      debounce = false
end)
1 Like

Just a side note, you probably want to check if the player is typing in chat.

You dont want them accidentally triggering this event unintentionally.

Use gameProcessedEvent to prevent this from happening.

1 Like

Ya I get what you mean.

30characters

1 Like