Hey! I hope you are having a great day! Currently, I am trying to disconnect a RBXScriptConnection, but when I try this code:
game.ReplicatedStorage.LocalPlayerEvents.EndFixedCamera.Event:Connect(function()
if GoingInsideCamera ~= nil then
GoingInsideCamera:Disconnect()
end
if OutdoorCamera ~= nil then
OutdoorCamera:Disconnect()
end
GoingInsideCamera = nil
OutdoorCamera = nil
end)
It doesn’t seem to work. Is this not how to specify connections?
If you can help, please let me know. Thanks! WE
Edit: There are no errors, and the variables are RunService RenderStepped.
What are the variables GoingInsideCamera and OutdoorCamera? (Can you show them in the hierarchy). As well, I assume (please confirm), “EndFixedCamera” is a bindableEvent?
game.ReplicatedStorage.LocalPlayerEvents.EndFixedCamera.Event:Connect(function()
if GoingInsideCamera ~= nil then
--GoingInsideCamera:Disconnect()
RunService:UnbindFromRenderStep("GoingInsideCamera")
end
if OutdoorCamera ~= nil then
--OutdoorCamera:Disconnect()
RunService:UnbindFromRenderStep("OutdoorCamera")
end
GoingInsideCamera = nil
OutdoorCamera = nil
end)
local function OutdoorCamera()
local PlayerPosition = Character:WaitForChild("HumanoidRootPart").Position
local CameraPosition = PlayerPosition + offset
Camera.CoordinateFrame = CFrame.new(CameraPosition, PlayerPosition)
end
OutdoorCamera = RunService:BindToRenderStep("OutdoorCamera", 1, OutdoorCamera)
local function GoInCamera()
Camera.CFrame = CameraCFrame
end
GoingInsideCamera = RunService:BindToRenderStep("GoingInsideCamera", 1, GoInCamera)
It seems the camera not returning to it’s normal state is a completely different problem, try adding prints inside of the Functions being run on RenderStep to see if it stops printing when you unbind the function