Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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))
0
Thanks so much! SuperBeeperman 30 — 6y
Ad

Answer this question