So I am trying to attack the camera to the Ball part when it hits the Replay1 part but this code already attaches the camera to the ball before it touches.
local Replay1= game.Workspace.Replay1
if workspace.Ball.Touched:connect(function(Replay1)
end)
then
local camPart = workspace.Ball
repeat wait() until game:service("ContentProvider").RequestQueueSize ==0
local cam = workspace.CurrentCamera
cam.CameraSubject =camPart
cam.CameraType= Enum.CameraType.Attach
else
local camPart = workspace.Ball
repeat wait() until game:service("ContentProvider").RequestQueueSize ==0
local cam = workspace.CurrentCamera
cam.CameraSubject =camPart
cam.CameraType= Enum.CameraType.Attach
end

3 comments
Are you using a Local Script, and if so, where is the script located. Also, could you edit your code for a code block?
Local script in starterGUI
Edited for code block. In the future, please make a code block with the Lua button in creating or editing of posts.