Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

6 comments

4

It may be because you have script.Disabled which could cause it to disable the script before running all the code after it

0

Aside from what tj said, KeyDown is deprecated. Use UserInputService or ContextActionService.

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.

0

Incapaz is wrong. The script can reenable itself, if a function if it is called i.e. by an event it connected to.

0

^ only if it's disabled after the event is connected

0

Seems like a lot of hassle, instead of just making a debounce.

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.