local mouse = game.Players.LocalPlayer:GetMouse()
local cam = workspace.CurrentCamera
local camPart = workspace.campart
local Scale = 5000
cam.CameraType = Enum.CameraType.Scriptable
game:GetService("RunService").RenderStepped:Connect(function()
local center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
local x = mouse.X - center.X / 2
local y = mouse.Y - center.Y / 2
local xOffset = x/Scale
local yOffset = y/Scale
local lookAtPoint = camPart.Position+camPart.CFrame.LookVector*5
local vector = Vector3.new(
lookAtPoint.X - xOffset,
lookAtPoint.Y - yOffset,
lookAtPoint.Z - xOffset)
local result = CFrame.lookAt(camPart.CFrame.Position,vector)
cam.CFrame = result
end)
script.Parent.LoadGame.MouseButton1Click:Connect(function()
cam.CameraType = Enum.CameraType.Custom
print("OrigCam")
end)
There are no Errors and the print also worked, don’t know why. Please help me.
I dont know if thats the only issue, but you could do it like this:
local mouse = game.Players.LocalPlayer:GetMouse()
local cam = workspace.CurrentCamera
local camPart = workspace.campart
local Scale = 5000
cam.CameraType = Enum.CameraType.Scriptable
-- keep the connection into a variable
local RSrun = game:GetService("RunService").RenderStepped:Connect(function()
local center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
local x = mouse.X - center.X / 2
local y = mouse.Y - center.Y / 2
local xOffset = x/Scale
local yOffset = y/Scale
local lookAtPoint = camPart.Position+camPart.CFrame.LookVector*5
local vector = Vector3.new(
lookAtPoint.X - xOffset,
lookAtPoint.Y - yOffset,
lookAtPoint.Z - xOffset)
local result = CFrame.lookAt(camPart.CFrame.Position,vector)
cam.CFrame = result
end)
script.Parent.LoadGame.MouseButton1Click:Connect(function()
RSrun:Disconnect() -- disconnect it when needed
cam.CameraType = Enum.CameraType.Custom
print("OrigCam")
end)
local mouse = game.Players.LocalPlayer:GetMouse()
local cam = workspace.CurrentCamera
local camPart = workspace.campart
local Scale = 5000
cam.CameraType = Enum.CameraType.Scriptable
fart = game:GetService("RunService").RenderStepped:Connect(function()
local center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
local x = mouse.X - center.X / 2
local y = mouse.Y - center.Y / 2
local xOffset = x/Scale
local yOffset = y/Scale
local lookAtPoint = camPart.Position+camPart.CFrame.LookVector*5
local vector = Vector3.new(
lookAtPoint.X - xOffset,
lookAtPoint.Y - yOffset,
lookAtPoint.Z - xOffset)
local result = CFrame.lookAt(camPart.CFrame.Position,vector)
cam.CFrame = result
end)
script.Parent.LoadGame.MouseButton1Click:Connect(function()
cam.CameraType = Enum.CameraType.Custom
fart:Disconnect()
print("Set to OrigCam")
end)