Snippet of my code, where SelectedPart is an ObjectValue with the value of a model stored in ReplicatedStorage.
1 | local model = script.SelectedPart |
2 |
3 | local cloneModel = model:clone() |
4 | cloneModel.Parent = game.Workspace |
5 |
6 | local modelCFrame = cloneModel:GetModelCFrame() |
7 | mouse.TargetFilter = cloneModel |
The error when I run is 'GetModelCFrame is not a valid member of ObjectValue'
How do I fix this?
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).
1 | local model = script.SelectedPart |
2 |
3 | local cloneModel = model.Value:clone() --Index the Value |
4 | cloneModel.Parent = game.Workspace |
5 |
6 | local modelCFrame = cloneModel:GetModelCFrame() |
7 | mouse.TargetFilter = cloneModel |