Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my debounce not working correctly?

Hello, I've tried making a camera tweening script, which surprisingly enough, worked.

Now my problem was that you could just touch the part again, and the camera cutscene would start all over again, which I don't want.

So I made debounce, and it doens't seem to work, does anyone know why?

Script:


local cam = workspace.CurrentCamera
local TweenSerivce = game:GetService("TweenService")
local debounce = false

game.Workspace.Part.Touched:Connect(function()
	if not debounce then debounce = true
	debounce = true
	cam.CFrame = CFrame.new(10,10,10)
	cam.CameraType = Enum.CameraType.Scriptable
	local tweeninfo = TweenInfo.new(5, Enum.EasingStyle.Back, Enum.EasingDirection.In)
	local ECFrame = CFrame.new(20,20,20)
	local RECFrame = CFrame.new(40,40,40)
	local tween = TweenSerivce:Create(cam, tweeninfo, {CFrame = ECFrame})
	local SecondTween = TweenSerivce:Create(cam, tweeninfo, {CFrame = RECFrame})
	tween:Play()
	SecondTween:Play()
	cam.CameraType = Enum.CameraType.Custom
	debounce = false
	end
end)

Thanks for your time

1 answer

✓ Accepted answer

Instead of writing:

if not debounce then

Write:

if debounce then  -- (if debounce == true then) 

Have a nice day, dont forget to accept answer if it worked ;)

2 comments

0

Thanks!

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.