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

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

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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
Ad

Answer this question