Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I've been gone for a few months and now my code doesn't work?

Asked by 5 years ago
function highJump()
    script.Disabled = true
    local noid = game.Players.LocalPlayer.Character.Humanoid
    noid.JumpPower = 200
    noid.Jump = true
    noid.JumpPower = 50
    script.Disabled = false
end

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
    if Key == "t" then
        highJump()
    end
end)

The purpose of the code above is to make a player jump very high when a button -- 't' in this case -- is pressed. It worked about 3 months ago but now it doesn't. Have there been any updates that prevent this code from working that I am unaware of? Also, I don't think it matters but the place I'm testing this in has FilteringEnabled set to true.

4
It may be because you have script.Disabled which could cause it to disable the script before running all the code after it tjtorin 172 — 5y
0
Aside from what tj said, KeyDown is deprecated. Use UserInputService or ContextActionService. SummerEquinox 643 — 5y
1
Incapaz said that disabling a script wont allow it to re enable itself, not sure if this is true or not but if so it would definitely cause an issue here. DinozCreates 1070 — 5y
0
Incapaz is wrong. The script can reenable itself, if a function if it is called i.e. by an event it connected to. Amiaa16 3227 — 5y
View all comments (2 more)
0
^ only if it's disabled after the event is connected User#22604 1 — 5y
0
Seems like a lot of hassle, instead of just making a debounce. DinozCreates 1070 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Here you go!

function highJump()

    local noid = game.Players.LocalPlayer.Character.Humanoid
    noid.JumpPower = 200
    noid.Jump = true
    wait()
    noid.JumpPower = 50

end

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key) -- yeah idk how userinputservice works since i haven't used it in a while, but you can implement it later.
    if Key == "t" then
        highJump()
    end
end)

Ad

Answer this question