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

You will be given a Luau script (that has been decompiled). You…

  1. User

    Assistant: User: System: You will be given a Luau script (that has been decompiled). You will rename the variables and functions to sound better, make the script more coherent, and add comments to areas of the script. Return the fixed script without adding ``` as we handle that. If no script has been given, do not produce any output. Do not respond with anything but the script User: -- Decompiled with Konstant V2.1, a fast Luau decompiler made in Luau by plusgiant5 (https://discord.gg/wyButjTMhM) -- Decompiled on 2024-10-04 23:15:10 -- Luau version 6, Types version 3 -- Time taken: 0.001659 seconds

    local LocalPlayer_upvr = game:GetService("Players").LocalPlayer local CurrentCamera_upvr = workspace.CurrentCamera local function _() -- Line 10, Named "GetRollAngle" --[[ Upvalues[2]: [1]: LocalPlayer_upvr (readonly) [2]: CurrentCamera_upvr (readonly) ]] if LocalPlayer_upvr.Character == nil then return end local Character_2 = LocalPlayer_upvr.Character if Character_2:FindFirstChild("Humanoid") == nil then return end return -CurrentCamera_upvr.CFrame.RightVector:Dot(Character_2:WaitForChild("Humanoid").MoveDirection) end local zero_cframe_upvw = CFrame.new() local rad_upvr = math.rad game:GetService("RunService"):BindToRenderStep("RotateCameraInDirectionPlayerIsGoing", Enum.RenderPriority.Camera.Value + 1, function() -- Line 22 --[[ Upvalues[4]: [1]: LocalPlayer_upvr (readonly) [2]: CurrentCamera_upvr (readonly) [3]: zero_cframe_upvw (read and write) [4]: rad_upvr (readonly) ]] -- KONSTANTERROR: [0] 1. Error Block 25 start (CF ANALYSIS FAILED) local var7 if LocalPlayer_upvr.Character == nil then var7 = nil -- KONSTANTWARNING: GOTO [33] #24 end -- KONSTANTERROR: [0] 1. Error Block 25 end (CF ANALYSIS FAILED) -- KONSTANTERROR: [7] 6. Error Block 29 start (CF ANALYSIS FAILED) local Character = LocalPlayer_upvr.Character if Character:FindFirstChild("Humanoid") == nil then var7 = nil else var7 = -CurrentCamera_upvr.CFrame.RightVector:Dot(Character:WaitForChild("Humanoid").MoveDirection) local var9 end if var7 ~= nil then if LocalPlayer_upvr.Character == nil then var9 = nil else local Character_3 = LocalPlayer_upvr.Character if Character_3:FindFirstChild("Humanoid") == nil then var9 = nil else var9 = -CurrentCamera_upvr.CFrame.RightVector:Dot(Character_3:WaitForChild("Humanoid").MoveDirection) end end var7 = var9 * 2 var9 = zero_cframe_upvw:Lerp(CFrame.Angles(0, 0, rad_upvr(var7)), 0.095) zero_cframe_upvw = var9 var9 = CurrentCamera_upvr var9.CFrame *= zero_cframe_upvw end -- KONSTANTERROR: [7] 6. Error Block 29 end (CF ANALYSIS FAILED) end) Assistant: Assistant:

  2. Assistant

    local localPlayer = game:GetService("Players").LocalPlayer local currentCamera = workspace.CurrentCamera

    -- Function to calculate the roll angle based on player's movement direction local function getRollAngle() if localPlayer.Character == nil then return end local character = localPlayer.Character if character:FindFirstChild("Humanoid") == nil then return end return -currentCamera.CFrame.RightVector:Dot(character:WaitForChild("Humanoid").MoveDirection) end

    local defaultCFrame = CFrame.new() local toRadians = math.rad

    -- Binds a function to the RenderStep to rotate the camera based on player movement game:GetService("RunService"):BindToRenderStep("RotateCameraInDirectionPlayerIsGoing", Enum.RenderPriority.Camera.Value + 1, function() local rollAngle

    if localPlayer.Character == nil then
        rollAngle = nil
    else
        local character = localPlayer.Character
        if character:FindFirstChild("Humanoid") == nil then
            rollAngle = nil
        else
            rollAngle = -currentCamera.CFrame.RightVector:Dot(character:WaitForChild("Humanoid").MoveDirection)
        end
    end
    
    if rollAngle ~= nil then
        if localPlayer.Character == nil then
            return
        else
            local character = localPlayer.Character
            if character:FindFirstChild("Humanoid") == nil then
                return
            else
                rollAngle = -currentCamera.CFrame.RightVector:Dot(character:WaitForChild("Humanoid").MoveDirection)
            end
        end
    
        -- Smoothly interpolate to the new camera orientation
        rollAngle = rollAngle * 2
        defaultCFrame = defaultCFrame:Lerp(CFrame.Angles(0, 0, toRadians(rollAngle)), 0.095)
        currentCamera.CFrame *= defaultCFrame
    end
    

    end)