Categories > Exploiting > Roblox >

[HELP] How do I add a toggle on/off script?

Posts: 2

Threads: 1

Joined: Jun, 2021

Reputation: 0

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.

  • 0

Posts: 11

Threads: 0

Joined: Jun, 2021

Reputation: 0

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

  • 0

jaelyn

ᵇᵘˢʸ ᵘˢᶦⁿᵍ ᵈᵉᵛ ᶜ⁺⁺ ᵃᵖᵖᵃʳᵉⁿᵗˡʸ

discord: jaelyn#2129 Swed needs kithes

Posts: 2

Threads: 1

Joined: Jun, 2021

Reputation: 0

Replied

Hmm, I've tried implementing my code but it doesn't seem to work when I test it.

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )