.Changed fires 6 times

that is just annoying. something worth mentioning is that the first time OnCams is set to true literally nothing happens which makes it work in reverse somehow.

local CamsDebounce = false --//stupid camera hover thing
local OnCams = workspace.Technical.OnCams

local function CameraToggle() --//function instead so you can force the cameras down
	if OnCams.Value == false then
		OnCams.Value = true 
		game.ReplicatedStorage.Values.MouseLook.Value = false
		game.ReplicatedStorage.Values.Power.Usage.Value = game.ReplicatedStorage.Values.Power.Usage.Value + 0.2
		game.Workspace.FX.Camera:Play()
		script.Parent.Parent.CameraFrame.Visible = true
		game.Workspace.CurrentCamera.CFrame = game.Workspace.Cameras.Security.Cam01.CFrame
		script.Parent.Parent.Noise.Visible = true
		

	else

		OnCams.Value = false 
		game.ReplicatedStorage.Values.MouseLook.Value = true
		game.ReplicatedStorage.Values.Power.Usage.Value = game.ReplicatedStorage.Values.Power.Usage.Value - 0.2
		game.Workspace.FX.Camera:Play()
		script.Parent.Parent.CameraFrame.Visible = false
		game.Workspace.CurrentCamera.CFrame = game.Workspace.Cameras.OfficeCamera.CFrame
		script.Parent.Parent.Noise.Visible = false
	end
end

OnCams.Changed:Connect(CameraToggle)

script.Parent.MouseEnter:Connect(function()
	if not CamsDebounce then
		CamsDebounce = true
		task.delay(0.3, function()
			CamsDebounce = false
		end)
		if OnCams.Value == false then
			OnCams.Value = true
		else
			OnCams.Value = false
		end
	end
end)


--//debug thingy

--task.spawn(function()
--	while task.wait() do
--		print(CamsDebounce)
--	end
--end)
2 Likes

It could be because .Changed fires for any property changed. If you want to be more specific, try using “GetPropertyChangedSignal”, for which you can find the documentation for here

it’s just a bool value. there’s no other property change lol

didn’t fix anything

1 Like

Wouldn’t .Changed fire when you change it in that function?

This is what I’m talking about.

2 Likes

Just telling you that might cause a problem. Not asking why you put it there, I’m asking if you have taken that into account.

3 Likes

oh my god i just realized what you meant oh my god :sob: but why doesn’t it do anything the first time?

edit: checked for false instead of true. got reminded of this thread. thanks everyone!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.