My debounce is not working for some reason, It’s just stuck on the camera part.
If I provided little details, please tell me.
Here’s the actual script.
local UIS = game:GetService("UserInputService")
local inuse = false
local debounce = true
local function on()
inuse = true
while inuse == true do
workspace.CurrentCamera.CameraType = "Scriptable"
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Head
workspace.CurrentCamera.CoordinateFrame = CFrame.new(workspace.CameraPart.Position, game.Players.LocalPlayer.Character.Head.Position)
game:GetService('RunService').RenderStepped:wait()
end
end
local function off()
inuse = false
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Four and debounce == true then
on()
debounce = false
elseif debounce == false then
off()
debounce = true
end
end)
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Four then
if debounce == true then
debounce = false
on()
elseif debounce == false then
debounce = true
off()
end
end
end)
No that’s most likely not the issue. The problem is that the function on() doesn’t stop since it’s in a while loop so the next line (where you set the debounce to false) will never be executed.