Basically, when you left click the ClickDetector on the part, it should change the part to the CFrame of the MenuCam, but it won’t work. I got the script from a GUI title screen thing I found, so I might believe that’s the reason, but other than that, I dunno.
Here’s the script:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.Menu.MenuCam.CFrame
camera.FieldOfView = 120
print("did it work?")
end)
I’ve been trying to do this for the past 20 minutes to no avail. I’ve searched other places on the DevForum and it didn’t help much.
-- server script
local remote = game.ReplicatedStorage.RemoteEvent -- add a remote event
script.Parent.ClickDetector.MouseClick:Connect(function(player)
remote:FireClient(player)
end)
-- local script
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnClientEvent:Connect(function()
local player = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.Menu.MenuCam.CFrame
camera.FieldOfView = 120
print("did it work?")
end)
I put the script/local script/remove event into the right place but it still doesn’t work. It also won’t print the text/any errors, so I’m checking to see if anything before the print is broken.
You have to change the remoteevent’s name to whatever you like, then in the server and client, change “NameOfYourRemoteEvent” to, well, the name of the remote event.
One issue that stands out is that you’re redefining the plr variable inside the function, which is unnecessary since you’re already passing it as a parameter to the function. And, the wait() function inside the repeat loop doesn’t have a specific purpose and can be removed.
Here’s a fixed version:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = workspace.Menu.MenuCam.CFrame
camera.FieldOfView = 120
print("did it work?")
You don’t need double “plr”, otherwise, the game is confused.
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local cameragoal1 = 120
local cameragoal2 = 70
repeat task.wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
task.wait(0.07)
if camera.CameraType == Enum.CameraType.Scriptable and camera.FieldOfView == cameragoal2 then
camera.CFrame = workspace.Menu.MenuCam.CFrame
camera.FieldOfView = cameragoal1
print("Worked.")
print("FOV: "..camera.FieldOfView)
elseif camera.CameraType == not Enum.CameraType.Scriptable then
print("Why is the Camera not Scriptable? Oh yeah, we didn't waited long enough, or the camera won't be scriptable.")
--Do you want more if the camera's FOV is 120?
elseif camera.FieldOfView == cameragoal1 then
camera.FieldOfViev = cameragoal2
print("FOV: "..camera.FieldOfView)
end
end)