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

Creating instances of models?

I am trying to spawn a copy of a brick that I made, but it says :Unable to create an Instance of type "modeledAttacker". Here is the code

local base = script.Parent
 local modeledAttacker = game.Workspace.attacker


function createAttacker()
	attacker = Instance.new("modeledAttacker",Workspace) -- problem originates here
	attacker.Position = Vector3.new( -33, 3, 18)
end

createAttacker()

1 answer

✓ Accepted answer

Ok, so to create an exact instance of an instance that already exists, use :Clone()

So, to fix your problem:

local base = script.Parent
	local modeledAttacker = game.Workspace.attacker


function createAttacker()
	attacker = modeledAttacker:clone() -- You clone it here
	attacker:MakeJoints() -- Keeps the model together, just to be sure
	attacker.Parent = game.Workspace -- When you clone it the parent defaults to nil
	attacker.Position = Vector3.new( -33, 3, 18)
end

createAttacker()

1 comment

0

thanks!

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