Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"Argument 1 missing or nil" error popping up on Output, any ideas?

the error is in the title, it appears to be a problem in line 24, any help?

local UserInputService = game:GetService('UserInputService')

local Player = game.Players.LocalPlayer
local CarOwned = Player.CarOwned.Value
UserInputService.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then
local function moveModel(Model, DesiredCFrameAngle)
    local Primary = workspace:FindFirstChild(CarOwned).PrimaryPart or error("Model has no PrimaryPart")
    local PrimaryCF = Primary.CFrame
    local Cache = {}
    for _, Desc in next, Model:GetDescendants() do
        if Desc ~= Primary and Desc:IsA("BasePart") then
            Cache[Desc] = PrimaryCF:toObjectSpace(Desc.CFrame)
        end
    end
    DesiredCFrameAngle = PrimaryCF * DesiredCFrameAngle
    Primary.CFrame = DesiredCFrameAngle
    for Part, Offset in next, Cache do
        Part.CFrame = DesiredCFrameAngle * Offset
    end
    
end

local rotModel = moveModel(workspace:FindFirstChild(CarOwned), CFrame.Angles(0, math.rad(260), 160))
	end
end)

1 answer

✓ Accepted answer

You're assigning CarOwned to the value property of the CarOwned object. The variable will not be reassigned if the value of the value object changes later. Instead you should assign it to the instance itself:

local CarOwned = Player.CarOwned

and then index its value when needed:

local rotModel = moveModel(workspace:FindFirstChild(CarOwned.Value))

1 comment

0

Thanks so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.