I've tried to change this script countless times to make it work online, but it doesn't, I don't understand why it doesn't work because it's in a local script. BTW, there's nothing wrong with the box part, it's the camera part that isn't working -- works fine in studio though
local Button = script.Parent
local Box = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.ActualHats.Frame.PirateHatz
local cam = game.workspace.CurrentCamera
function OnButtonClick()
Box.Visible = true
cam.CameraSubject= game.workspace.StoreWall
cam.CameraType = "Attach"
end
script.Parent.MouseButton1Down:connect(OnButtonClick)

3 comments
The cam might not exist yet when the variable is being made. Try using 'local cam = game.Workspace:WaitForChild("CurrentCamera")'
Didn't work, thanks for the reply tho
CurrentCamera should already exist on the client. Try adding a WaitForChild for one of your items in the box variable instead.