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

make contextactionservice stay the way it is once keybind is pressed unless it is pressed again?

Asked by 2 years ago
Edited 2 years ago

I want it to act like a userinputservice gui, once it is pressed, it stays open until the key is pressed again, which it then closes (another example is shiftlock, keeps the offset to 1.75 then once shift is pressed again, it changed to 0,0,0). I can't seem to find anything on the internet, can anyone help?

here is my script btw

local cas = game:GetService("ContextActionService") local tween = game:GetService("TweenService")

local char = game.Players.LocalPlayer.Character local hum = char:WaitForChild("Humanoid")

local debounce = false

local function offset() if not debounce then debounce = true tween:Create(char:WaitForChild("Humanoid"), TweenInfo.new(0.5), {CameraOffset = Vector3.new(1.75, 0, 0)}):Play() else debounce = false tween:Create(char:WaitForChild("Humanoid"), TweenInfo.new(0.5), {CameraOffset = Vector3.new(0, 0, 0)}):Play() end end

cas:BindAction("offset", offset, true, Enum.KeyCode.X)

Answer this question