When I press a button I want it to stop (RunService.Stepped) before doing this you press a button, it makes the camera look at an object and it's working correctly! But if i want the camera to go back to normal, i need to stop Run.Service.Stepped, I Cannot Find anyway of stopping it so far.
function UpdateCam() local CFam = CFrame.new(script.Parent.Parent.Character.PrimaryPart.CFrame.Position, workspace.Dummy.PrimaryPart.CFrame.Position) local CamCFam = CFam*CFrame.new(0, 3, 0) print(CamCFam) workspace.CurrentCamera.CFrame = CamCFam end UIS.InputBegan:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.L then if LisOn == false then LisOn = true RunService.Stepped:Connect(UpdateCam) print("camera changed new") elseif LisOn == true then LisOn = false RunService.Stepped:Disconnect(UpdateCam) -- I want it to be here but this won't work print("camera changed old") end end end)
You cannot disconnect events. You can disconnect functions from events by declaring them as variables. In your case, it would be like this:
local stepped = nil -- this is necessary stepped = RunService.Stepped:Connect(function() end) stepped:Disconnect()