As you see in the video, when I click the button my camera attaches to a block and when I click again it does nothing. It was supposed to get back to the player.
Script & hierarchy
local attached = false
local attachButton = script.Parent
attachButton.MouseButton1Click:Connect(function()
if attached then
workspace.CurrentCamera.CameraSubject = nil
attached = false
else
local block = script.Component.Value
if block then
workspace.CurrentCamera.CameraSubject = block
attached = true
end
end
end)
(Component is an object value and attached to the āblockā)
AND no output errors
local attached = false
local attachButton = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
attachButton.MouseButton1Click:Connect(function()
if attached then
workspace.CurrentCamera.CameraSubject = Character
attached = false
else
local block = script.Component.Value
if block then
workspace.CurrentCamera.CameraSubject = block
attached = true
end
end
end)