Weld camera to a moving brick

Alright, the code is great and works perfectly. Just the thing is when I try to adapt it to the other button is just puts error. I try closing it adding new function called closed, but later call gets error or doesn’t connect to the function.

I think that’s because its only within the local scope. Try removing local from call and then forward declare the call variable, so that it is in the global scope.

Alright, after editing the variables and changing some code removing local scope. I get errors saying ‘got oeuf with end’ when a end should be there. (Also sorry for taking most of you time with this)

If you provide your current code, I can take a look for you. It’s no bother either, this is why the forums exist - if you need anything explaining, I shall try to the best of my knowledge.

Alright, here you may have the small edit I did to code. It now doesn’t work but stop saying errors.

local RunService = game:GetService("RunService")

local currentCamera = workspace.CurrentCamera
local button2 = script.Parent.Parent.FixCam
local button = script.Parent
local cameraPart = workspace.A320CFM.PlaneKit.Plane.OtherParts.Tail


	 function update()
		
		currentCamera.CFrame = cameraPart.CFrame
	end
function stop()
	local call = RunService.RenderStepped:Connect(update)
	

	call:Disconnect(update)
	print("time")

end

button.MouseButton1Click:Connect(update())
button2.MouseButton1Click:Connect(stop())

local RunService = game:GetService("RunService")

local currentCamera = workspace.CurrentCamera

local screenGUI = script.Parent

local open = screenGUI.Open
local close = screenGUI.Close

local cameraPart = workspace.Part

local call

local function fire()
	print("Fired")
	local function update()
		
		currentCamera.CFrame = cameraPart.CFrame
	end

	call = RunService.RenderStepped:Connect(update)

end

open.MouseButton1Click:Connect(fire)
close.MouseButton1Click:Connect(function()
	if not call then return end
	print("Disconnected")
	call:Disconnect()
	call = nil
end)

This was my quick approach.

It works perfectly! Thank you for helping me. Have a great day.

I’ll mark it as solved right now, literally I want to thank you a lot! :grinning: