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

[SOLVED] GetModelCFrame is not a valid member of ObjectValue?

Snippet of my code, where SelectedPart is an ObjectValue with the value of a model stored in ReplicatedStorage.

    local model = script.SelectedPart

    local cloneModel = model:clone()
    cloneModel.Parent = game.Workspace

    local modelCFrame = cloneModel:GetModelCFrame()
    mouse.TargetFilter = cloneModel

The error when I run is 'GetModelCFrame is not a valid member of ObjectValue'

How do I fix this?

1 answer

✓ Accepted answer

Seems like 'model' is an ObjectValue. This is okay, but ObjectValues don't support the GetModelCFrame function. You have to index it's Value property in order to reference the Model it holds(assuming the Value IS actually a model).

local model = script.SelectedPart

local cloneModel = model.Value:clone() --Index the Value
cloneModel.Parent = game.Workspace

local modelCFrame = cloneModel:GetModelCFrame()
mouse.TargetFilter = cloneModel

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