I made a script that makes it so if you type ‘Q’ it rotates the camera by 90 degrees. But when I double tap Q it turns it twice so therefore it turns 90 degrees twice, turning itself around(Which I don’t want)
Here’s my script:
local ts = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local part = workspace:WaitForChild("Campart")
camera.CameraType = Enum.CameraType.Scriptable
cameraCFrame = part.CFrame
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
camera.CameraType = Enum.CameraType.Scriptable
local Tweeninfo = TweenInfo.new(0.5) --time of tween
ts:Create(camera,Tweeninfo,{CFrame = CFrame.new(0,90,0)}):Play()
end
uis.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
--[[
local Tweeninfo = TweenInfo.new(0.5) --time of tween
ts:Create(camera,Tweeninfo,{CFrame = part.CFrame}):Play()
--]]
end
end)
end)
local ts = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local part = workspace:WaitForChild("Campart")
camera.CameraType = Enum.CameraType.Scriptable
cameraCFrame = part.CFrame
local inTransition = false
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q and not inTransition then
inTransition = true
camera.CameraType = Enum.CameraType.Scriptable
local Tweeninfo = TweenInfo.new(0.5) --time of tween
ts:Create(camera,Tweeninfo,{CFrame = CFrame.new(0,90,0)}):Play()
end
end)
uis.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q and inTransition then
inTransition = false
local Tweeninfo = TweenInfo.new(0.5) --time of tween
ts:Create(camera,Tweeninfo,{CFrame = part.CFrame}):Play()
end
end)
the use of a debounce is what you need but only reset the debounce after the tween finishes not on input ended
the rotational part of the camera cframe may need fixed in your script but here is how you use the debounce correctly
local ts = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local debounce -- used to keep from doubling until tween is done
local part = workspace:WaitForChild("Campart")
camera.CameraType = Enum.CameraType.Scriptable
cameraCFrame = part.CFrame
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q and not debounce then
debounce = true -- set so it doesn't run again
camera.CameraType = Enum.CameraType.Scriptable
local Tweeninfo = TweenInfo.new(0.5) --time of tween
local Tween = ts:Create(camera,Tweeninfo,{CFrame = CFrame.new(0,90,0)})
Tween:Play()
Tween.Completed:Wait() -- wait until camera tween finishes
print('finished')
debounce = nil -- remove the debounce
end
end)
uis.InputEnded:Connect(function(input) -- this needs to be outside of inputbegin else it will make multi connections
if input.KeyCode == Enum.KeyCode.Q then
--[[
local Tweeninfo = TweenInfo.new(0.5) --time of tween
ts:Create(camera,Tweeninfo,{CFrame = part.CFrame}):Play()
--]]
end
end)