Skip to content
TheChatArchiveThe Chat Archive
Metallama-4-maverick-17b-128e-instruct· MetaHugging Face LMArena Human Preference 140K

can you make, so once players goes inside of first camera with shiftlock enabled, their…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o3-2025-04-16’s answer.
  1. User

    can you make, so once players goes inside of first camera with shiftlock enabled, their camera goes in default position

    local RunService = game:GetService("RunService")
    local Players = game:GetService("Players")
    local UserInputService = game:GetService("UserInputService")
    
    local CurrentCamera = workspace.CurrentCamera
    local Player = Players.LocalPlayer
    local Mouse = Player:GetMouse()
    
    local mouseLockLabel = script.Parent
    local mouseLock = nil
    
    local SHIFT_LOCK_OFF = 'rbxasset://textures/ui/mouseLock_off.png'
    local SHIFT_LOCK_ON = 'rbxasset://textures/ui/mouseLock_on.png'
    local SHIFT_LOCK_CURSOR = 'rbxasset://textures/MouseLockedCursor.png'
    
    local MaxLength = 900000
    local EnabledOffset = CFrame.new(1.7, 0, 0)
    local DisabledOffset = CFrame.new(-1.7, 0, 0)
    
    local function shiftLock(active)
    	local Character = Player.Character
    	if not Character or not Character:FindFirstChild("Humanoid") then return end
    	local hum = Character.Humanoid
    	local root = hum.RootPart
    
    	if active then
    		hum.CameraOffset = Vector3.new(1.75, 0, 0)
    		hum.AutoRotate = false
    
    		RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
    			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
    
    			local _, y = CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
    			root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, y, 0)
    		end)
    
    		Mouse.Icon = SHIFT_LOCK_CURSOR
    		mouseLockLabel.Image = SHIFT_LOCK_ON
    	else
    		hum.CameraOffset = Vector3.new(0, 0, 0)
    		RunService:UnbindFromRenderStep("ShiftLock")
    
    		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
    		hum.AutoRotate = true 
    
    		Mouse.Icon = "http://www.roblox.com/asset/?id=7025168168"
    		mouseLockLabel.Image = SHIFT_LOCK_OFF
    	end
    end
    
    local function shiftLockSwitcher()
    	if mouseLock then
    		mouseLock:Disconnect()
    		mouseLock = nil
    		shiftLock(false)
    		CurrentCamera.CFrame = CurrentCamera.CFrame * DisabledOffset
    	else
    		mouseLock = RunService.Heartbeat:Connect(function()
    			local Character = Player.Character
    			if Character and Character:FindFirstChild("Humanoid") and Character:FindFirstChild("HumanoidRootPart") then
    				local hum = Character.Humanoid
    				local root = Character.HumanoidRootPart
    
    				hum.AutoRotate = false
    				root.CFrame = CFrame.new(
    					root.Position,
    					Vector3.new(
    						CurrentCamera.CFrame.LookVector.X * MaxLength,
    						root.Position.Y,
    						CurrentCamera.CFrame.LookVector.Z * MaxLength
    					)
    				)
    				CurrentCamera.CFrame = CurrentCamera.CFrame * EnabledOffset
    				CurrentCamera.Focus = CFrame.fromMatrix(
    					CurrentCamera.Focus.Position,
    					CurrentCamera.CFrame.RightVector,
    					CurrentCamera.CFrame.UpVector
    				) * EnabledOffset
    			end
    		end)
    		shiftLock(true)
    	end
    end
    
    mouseLockLabel.MouseButton1Click:Connect(shiftLockSwitcher)
    UserInputService.InputBegan:Connect(function(input)
    	if input.KeyCode == Enum.KeyCode.LeftShift then
    		shiftLockSwitcher()
    	end
    end)
    
  2. Meta Assistant

    To achieve the desired behavior, you need to detect when the player enters the first camera's region and reset the camera to its default position when shiftlock is enabled.

    Here's an updated version of your script that includes this functionality:

    local RunService = game:GetService("RunService")
    local Players = game:GetService("Players")
    local UserInputService = game:GetService("UserInputService")
    
    local CurrentCamera = workspace.CurrentCamera
    local Player = Players.LocalPlayer
    local Mouse = Player:GetMouse()
    
    local mouseLockLabel = script.Parent
    local mouseLock = nil
    
    local SHIFT_LOCK_OFF = 'rbxasset://textures/ui/mouseLock_off.png'
    local SHIFT_LOCK_ON = 'rbxasset://textures/ui/mouseLock_on.png'
    local SHIFT_LOCK_CURSOR = 'rbxasset://textures/MouseLockedCursor.png'
    
    local MaxLength = 900000
    local EnabledOffset = CFrame.new(1.7, 0, 0)
    local DisabledOffset = CFrame.new(-1.7, 0, 0)
    
    -- Define the region of the first camera
    local firstCameraRegion = workspace:FindFirstChild("FirstCameraRegion") -- Replace with your region's name
    if not firstCameraRegion then
        error("FirstCameraRegion not found in workspace")
    end
    
    local function isPlayerInRegion(region, character)
        if not character or not character:FindFirstChild("HumanoidRootPart") then return false end
        local root = character.HumanoidRootPart
        return region:IsInside(root.Position)
    end
    
    local function shiftLock(active)
        local Character = Player.Character
        if not Character or not Character:FindFirstChild("Humanoid") then return end
        local hum = Character.Humanoid
        local root = hum.RootPart
    
        if active then
            hum.CameraOffset = Vector3.new(1.75, 0, 0)
            hum.AutoRotate = false
    
            RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
                UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
    
                local _, y = CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
                root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, y, 0)
    
                -- Check if player is in the first camera region
                if isPlayerInRegion(firstCameraRegion, Character) then
                    -- Reset camera to default position
                    CurrentCamera.CFrame = CurrentCamera.CFrame * CFrame.new(0, 0, 0) -- You can adjust this to your desired default position
                end
            end)
    
            Mouse.Icon = SHIFT_LOCK_CURSOR
            mouseLockLabel.Image = SHIFT_LOCK_ON
        else
            hum.CameraOffset = Vector3.new(0, 0, 0)
            RunService:UnbindFromRenderStep("ShiftLock")
    
            UserInputService.MouseBehavior = Enum.MouseBehavior.Default
            hum.AutoRotate = true 
    
            Mouse.Icon = "http://www.roblox.com/asset/?id=7025168168"
            mouseLockLabel.Image = SHIFT_LOCK_OFF
        end
    end
    
    local function shiftLockSwitcher()
        if mouseLock then
            mouseLock:Disconnect()
            mouseLock = nil
            shiftLock(false)
            CurrentCamera.CFrame = CurrentCamera.CFrame * DisabledOffset
        else
            mouseLock = RunService.Heartbeat:Connect(function()
                local Character = Player.Character
                if Character and Character:FindFirstChild("Humanoid") and Character:FindFirstChild("HumanoidRootPart") then
                    local hum = Character.Humanoid
                    local root = Character.HumanoidRootPart
    
                    hum.AutoRotate = false
                    root.CFrame = CFrame.new(
                        root.Position,
                        Vector3.new(
                            CurrentCamera.CFrame.LookVector.X * MaxLength,
                            root.Position.Y,
                            CurrentCamera.CFrame.LookVector.Z * MaxLength
                        )
                    )
                    CurrentCamera.CFrame = CurrentCamera.CFrame * EnabledOffset
                    CurrentCamera.Focus = CFrame.fromMatrix(
                        CurrentCamera.Focus.Position,
                        CurrentCamera.CFrame.RightVector,
                        CurrentCamera.CFrame.UpVector
                    ) * EnabledOffset
                end
            end)
            shiftLock(true)
        end
    end
    
    mouseLockLabel.MouseButton1Click:Connect(shiftLockSwitcher)
    UserInputService.InputBegan:Connect(function(input)
        if input.KeyCode == Enum.KeyCode.LeftShift then
            shiftLockSwitcher()
        end
    end)
    

    Note: You need to create a Region3 object in your workspace and name it "FirstCameraRegion". You can do this by creating a Part and using the Region3 function to create a region around it.

    Here's an example of how to create a Region3 object:

    local part = Instance.new("Part")
    part.Size = Vector3.new(10, 10, 10) -- Adjust the size to your desired region size
    part.Transparency = 1
    part.CanCollide = false
    part.Parent = workspace
    
    local region = Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)
    firstCameraRegion = region
    

    You can then use this Region3 object in your script to detect when the player enters the region.

    Alternatively, you can use a BasePart and check if the player's character is inside it using the Touches function or a simple distance check.

    Make sure to adjust the script according to your specific use case.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.