Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

wait(1); cam = workspace.CurrentCamera; pal = game.Players.LocalPlayer.Character; local…

  1. User

    wait(1); cam = workspace.CurrentCamera; pal = game.Players.LocalPlayer.Character; local Player = game.Players.LocalPlayer local mouse = Player:GetMouse() local run = game:GetService("RunService") local maxDegree = math.rad(80)

    deb = "TPS";

    function updatetransparency(targ,bool) for i,v in pairs(targ:GetChildren()) do if v:IsA("Accessory") then updatetransparency(v,bool) elseif v:IsA("BasePart") then --HatAttachment FaceCenterAttachment HairAttachment NeckAttachment if v:FindFirstChild("HatAttachment") or v:FindFirstChild("FaceCenterAttachment") or v:FindFirstChild("FaceFrontAttachment") or v:FindFirstChild("FaceRearAttachment") or v:FindFirstChild("HairAttachment") or v:FindFirstChild("NeckAttachment") then if bool then v.LocalTransparencyModifier = 1 else v.LocalTransparencyModifier = v.Transparency end end end end end

    function updatechartransparency(targ,bool) for i,v in pairs(targ:GetChildren()) do if v:IsA("BasePart") then if bool or v.Name == "Head" then v.LocalTransparencyModifier = 1 else v.LocalTransparencyModifier = v.Transparency end updatetransparency(v,bool) elseif v:IsA("Folder") or v:IsA("Model") then updatetransparency(v,bool) end end end

    local renderrrrrr = game:GetService("RunService").RenderStepped; script.Parent.MouseButton1Click:connect(function() if deb == "FPS" then if Player.Character then cam.CameraType = "Custom"; deb = "TPS" local char = Player.Character if char:FindFirstChild("Humanoid") then cam.CameraSubject = char.Humanoid script.Parent.Parent.PreviewFP.Text = "IN THIRD PERSON VIEW" cam.FieldOfView = 70 end updatetransparency(Player.Character) end elseif deb == "TPS" then if Player.Character then cam.CameraType = "Custom"; deb = "TPSHead" local char = Player.Character if char:FindFirstChild("Head") then cam.CameraSubject = char.Head script.Parent.Parent.PreviewFP.Text = "IN THIRD PERSON VIEW (HEAD FOCUS)" cam.FieldOfView = 70 end updatetransparency(Player.Character) end elseif deb == "TPSHead" then cam.CameraType = "Scriptable"; deb = "FPS" script.Parent.Parent.PreviewFP.Text = "IN FIRST PERSON VIEW"

    	if Player.Character then
    		updatetransparency(Player.Character,true)
    		updatechartransparency(Player.Character)
    		cam.FieldOfView = 90
    	end
    	while true do
    		if Player.Character then
    			local char = Player.Character
    
    			if char:FindFirstChild("Head") then
    				local np = Vector2.new(mouse.X, mouse.Y)
    				local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
    				local difference = np - centre
    
    				local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)
    
    				cam.CFrame = char.Head.CFrame
    					* CFrame.new(0,0,(-char.Head.Size.Z/2)*1.25)
    					* CFrame.Angles(-outcome.X, -outcome.Y,0)
    			end
    		end
    		renderrrrrr:wait();
    		if deb ~= "FPS" or not Player.Character then
    			break;
    		end;		
    	end;
    end
    
    --[[
    local np = Vector2.new(mouse.X, mouse.Y)
    local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
    local difference = np - centre
    
    local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)
    
    cam.CFrame = campartttt.CFrame * CFrame.Angles(-outcome.X, -outcome.Y,0)
    ]]
    

    end);

    optimize this and make this readable. don't add comments and don't add explanations.

  2. Assistant
    wait(1)
    local cam = workspace.CurrentCamera
    local player = game.Players.LocalPlayer
    local runService = game:GetService("RunService")
    local maxDegree = math.rad(80)
    local deb = "TPS"
    
    local function updateTransparency(target, isTransparent)
        for _, v in pairs(target:GetChildren()) do
            if v:IsA("Accessory") then
                updateTransparency(v, isTransparent)
            elseif v:IsA("BasePart") then
                if v:FindFirstChild("HatAttachment") or 
                   v:FindFirstChild("FaceCenterAttachment") or 
                   v:FindFirstChild("FaceFrontAttachment") or 
                   v:FindFirstChild("FaceRearAttachment") or 
                   v:FindFirstChild("HairAttachment") or 
                   v:FindFirstChild("NeckAttachment") then
                    v.LocalTransparencyModifier = isTransparent and 1 or v.Transparency
                end
            end
        end
    end
    
    local function updateCharacterTransparency(character, isTransparent)
        for _, v in pairs(character:GetChildren()) do
            if v:IsA("BasePart") then
                v.LocalTransparencyModifier = (isTransparent or v.Name == "Head") and 1 or v.Transparency
                updateTransparency(v, isTransparent)
            elseif v:IsA("Folder") or v:IsA("Model") then
                updateTransparency(v, isTransparent)
            end
        end
    end
    
    script.Parent.MouseButton1Click:Connect(function()
        local char = player.Character
        if char then
            if deb == "FPS" then
                cam.CameraType = "Custom"
                deb = "TPS"
                if char:FindFirstChild("Humanoid") then
                    cam.CameraSubject = char.Humanoid
                    script.Parent.Parent.PreviewFP.Text = "IN THIRD PERSON VIEW"
                    cam.FieldOfView = 70
                end
                updateTransparency(char, false)
            elseif deb == "TPS" then
                cam.CameraType = "Custom"
                deb = "TPSHead"
                if char:FindFirstChild("Head") then
                    cam.CameraSubject = char.Head
                    script.Parent.Parent.PreviewFP.Text = "IN THIRD PERSON VIEW (HEAD FOCUS)"
                    cam.FieldOfView = 70
                end
                updateTransparency(char, false)
            elseif deb == "TPSHead" then
                cam.CameraType = "Scriptable"
                deb = "FPS"
                script.Parent.Parent.PreviewFP.Text = "IN FIRST PERSON VIEW"
                updateTransparency(char, true)
                updateCharacterTransparency(char, true)
                cam.FieldOfView = 90
                while deb == "FPS" and char do
                    local head = char:FindFirstChild("Head")
                    if head then
                        local mousePos = Vector2.new(player:GetMouse().X, player:GetMouse().Y)
                        local center = cam.ViewportSize / 2
                        local difference = mousePos - center
                        local outcome = Vector2.new((difference.Y / center.Y) * maxDegree, (difference.X / center.X) * maxDegree)
                        cam.CFrame = head.CFrame * CFrame.new(0, 0, -head.Size.Z * 1.25) * CFrame.Angles(-outcome.X, -outcome.Y, 0)
                    end
                    runService.RenderStepped:Wait()
                end
            end
        end
    end)