Type checking CFrame comes up as userdata?

1: fixing what seems like a data type error which might be an issue on the luau engine
2: cframe / instance type is coming up as “userdata???” which is only accessible through meta-tables
3: changing variables, using print(type(HEAD.CFrame)) to confirm, checking if it’s there, re-setting it, literally everything. impossible to solve (personally) as I do not know these types of situations nor does my friend, line 71 throwing the error in question:
image

local OFFSET_BACKUP = Vector3.new()
local RUNSERVICE = game:GetService('RunService')
local PLAYERS = game:GetService('Players')
local PLAYER = PLAYERS.LocalPlayer
local CHARACTER = PLAYER.Character
local HUMANOID = CHARACTER:FindFirstChildOfClass('Humanoid')
local CAMERA = workspace.CurrentCamera
local CONFIG_CAM = require(script.config_cam)
local CONFIG_SHOWBODY = CONFIG_CAM.SHOW_BODY
local CONFIG_REMOVEDECALS = CONFIG_CAM.HIDE_DECALS
local CONFIG_SHOWACCESSORIES = CONFIG_CAM.SHOW_ACCESSORIES
local CONFIG_CAMERA_OFFSET = CONFIG_CAM.CAMERA_OFFSET
local X1, Y1, Z1 = CAMERA.CFrame:ToOrientation()
local X2, Y2, Z2 = CHARACTER.PrimaryPart.CFrame:ToOrientation()
local CAMPOS,TARGETCAMPOS = CAMERA.CoordinateFrame.p,CAMERA.CoordinateFrame.p 
local ANGLEX,TARGETANGLEX = 0,0
local ANGLEY,TARGETANGLEY = 0,0
local SENS = 1
local SMOOTHNESS = .05
local HEAD = CHARACTER:FindFirstChild('Head')
local UIS = game:GetService('UserInputService')

local CONTAINER = {
    RUNSERVICE,
    PLAYERS,
    PLAYER,
    CHARACTER,
    CAMERA,
    CONFIG_CAM,
    CONFIG_SHOWBODY,
    CONFIG_REMOVEDECALS,
    CONFIG_SHOWACCESSORIES,
    CONFIG_CAMERA_OFFSET
}
for _,_v in ipairs(CONTAINER) do
    --if not _v then return error('Instanced variable of container table was not properly added or registered.') end
end
local function ADVSEARCH(loc)
    if not loc then return print('no search-thru location provided') end
    for _,_v in pairs(loc:GetDescendants()) do
        if _v:IsA(
            'BasePart') and loc and not _v:IsA('Accoutrement') and _v.Name ~= ('Handle') and _v.Name ~= ('Head') then
            _v.LocalTransparencyModifier = 0
            elseif _v.Name == ('Handle') then
            _v.LocalTransparencyModifier = 1
        elseif _v:IsA('Accoutrement') then
            _v:FindFirstChild(
                'Handle'
            ).LocalTransparencyModifier = 1
        elseif _v.Name == ('Head') then
            _v.LocalTransparencyModifier = 1
        end
        if _v:IsA(
            'Decal') then
            _v.Transparency = 1
        end
    end
end
task.spawn(function()
    RUNSERVICE.RenderStepped:Connect(function(_dElT)
        if not CHARACTER then return end
        if type(HEAD) ~= type(CFrame) then return end
        ADVSEARCH(CHARACTER)
        task.spawn(function() -- WBW (74-95)
            print(type(HEAD.CFrame))
            CAMPOS = CAMPOS + (TARGETCAMPOS - CAMPOS) *0.28 
            ANGLEX = ANGLEX + (TARGETANGLEX - TARGETANGLEX) *0.35 
            local dist = TARGETANGLEY - ANGLEY 
            dist = math.abs(dist) > 180 and dist - (dist / math.abs(dist)) * 360 or dist 
            ANGLEY = (ANGLEY + dist *0.35) %360
            CAMERA.CFrame = CFrame.new(HEAD.Position)
                * CFrame.Angles(0,math.rad(ANGLEY),0) 
                * CFrame.Angles(math.rad(ANGLEX),0,0)
                * CONFIG_CAMERA_OFFSET
            CHARACTER.PrimaryPart.CFrame=CFrame.new(CHARACTER.PrimaryPart.Position)*CFrame.Angles(0,math.rad(ANGLEY),0)
        end)
    end)
    UIS.InputChanged:connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement then
            local delta = Vector2.new(input.Delta.x/SENS,input.Delta.y/SENS) * SMOOTHNESS
            local X = TARGETANGLEX - delta.y 
            TARGETANGLEX = (X >= 80 and 80) or (X <= -80 and -80) or X 
            TARGETANGLEY = (TARGETANGLEY - delta.x) %360 
        end    
    end)
end)
3 Likes

what line is the error coming from?

71

charrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

Change both type to typeof.

Edit: Just to explain, type is from regular Lua. To retain backwards compatibility, it will correctly say that both Instance and CFrame are userdatas, because they are. However, typeof is the correct function if you want to differentiate between these types.

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.