Categories > Exploiting > Roblox >
[HELP] How do I add a toggle on/off script?
Posted
So basically, I'm not that good at wording but what I want is when I press a specific key it executes:
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 52
wait (0.2)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16.8
and when I press the specific key again, it executes:
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50
wait (0.2)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
tldr: I want to change my walkspeed/jumppower by pressing a specific key.
I do know I look like an idiot lol.
Replied
local toggle = false
local uis = game:GetService("UserInputService") -- UserInputService can detect keypresses
uis.InputBegan:Connect(function(key,gameprocessed)
if gameprocessed then return end -- player was chatting when the button was pressed
if key.KeyCode == Enum.KeyCode.A then
toggle = !toggle
if toggle then
-- run first code
else
-- run second code
end
end
end)
Use this method, replace Enum.KeyCode.A (the "A" key) with whatever you want
https://developer.roblox.com/en-us/api-reference/class/UserInputService
^ UIS api reference
Cancel
Post
jaelyn
ᵇᵘˢʸ ᵘˢᶦâ¿áµ ᵈᵉᵛ ᶜâºâº ᵃᵖᵖᵃʳᵉâ¿áµ—ˡʸ
discord: jaelyn#2129 Swed needs kithes
Replied
Hmm, I've tried implementing my code but it doesn't seem to work when I test it.
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post