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.
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)
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
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)