Hello there, I am using this script where my camera follows my mouse however I want to set it back to default on mouseclick in a button I made. Here is my script -
So set the camera type to custom on click on that button.
Doesn’t work however I’m not getting any errors.
Bring the camera type back to custom then add a debounce/disabler for the renderstepped maybe
Example:
if Default == true then return end
Didn’t work still. Is there anything else I can do?
what was the need of looping cameratype to Scriptable tho?
Because sometimes it wouldn’t run so I looped it until It was Scriptable.
Is the issue the camera not following your character?
Basically, the script right now is a script to make the camera slightly move with the players mouse however when they click a button, I would like it to set it back to the original.
Here is my disabler script -
local cam = workspace.CurrentCamera
script.Parent.MouseButton1Click:Connect(function()
cam.CameraType = Enum.CameraType.Custom
end)
Try This
local Cam = game.Workspace.CurrentCamera
local CamPart = game.Workspace["CameraPart"]
local Mouse = game.Players.LocalPlayer:GetMouse()
Cam.CameraType = Enum.CameraType.Scriptable
local MaxTilt = 10
local Dis = false
game:GetService("RunService").RenderStepped:Connect(function()
if Dis == false then
Cam.CFrame = CamPart.CFrame * CFrame.Angles(
math.rad(((Mouse.Y - Mouse.ViewSizeY / 2) / Mouse.ViewSizeY) * -MaxTilt),
math.rad(((Mouse.X - Mouse.ViewSizeX / 2) / Mouse.ViewSizeX) * -MaxTilt),
0
)
end
end)
script.Parent.MouseButton1Click:Connect(function()
Dis = true
Cam.CameraType = Enum.CameraType.Custom
Cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end)
Wow this works really well! Thank you so much I could not be any happier!!