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

Cloning Problem. Why?

I am VERY horrible at cloning. I have no concept of it whatsoever.

It's a pretty simple script. I just want to clone a model from the lighting and put it in the position of a brick. It keep saying 'Expected identifier, got '='' on line 3. I've tried .Parent after the :Clone() but it keeps saying that 'parent is not a valid member of Model'

if script.Parent.Parent.ArrowValue.Value == 0 then
Model = game.Lighting.M4A1M
Model:Clone() = script.Parent.Position
end

2 answers

✓ Accepted answer
Model:Clone() = script.Parent.Position

makes no sense whatsoever. There's nothing magic about scripting. Everything is logical.

What we need to do is store the cloned model in a variable, then Parent it to workspace and move it to that position. But Models don't have a position property, so we'll have to use MoveTo for the position.

Model = game.Lighting.M4A1M
local clone = Model:Clone()
clone.Parent = workspace
clone:MoveTo(script.Parent.Position)
if script.Parent.Parent.ArrowValue.Value == 0 then
Model = game.Lighting.M4A1M
local clone = Model:Clone() -- The Parent cannot be identified using an = sign, therefore, we will make it a local and change it in another line.
clone.Parent = script.Parent:FindFirstChild("Position")
end

I'm confused on whether you want to change the clone's position or Position is a model that you want the clone to be placed into.

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