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

Why can't I clone a model with this script. How would I clone this model?

I am trying to make a car spawner into a tool and I'm trying to clone the car and this isn't working. There are no errors and everything works but the cloning. Assets is a folder if that changes anything.

local tool = script.Parent
local clickEvent = tool.ClickEvent
local spawnblock = game.Workspace.spawnblock
local clickEventConnection

local function createPart(location)
	local work = game.Workspace
	local car = game.ReplicatedStorage.Assets.Car
	car.Parent = work
	car:MakeJoints()
	work.Car:MoveTo(spawnblock.Position)
	work.Car.Archivable = true
	work.Car:Clone().Parent = game.ReplicatedStorage.Assets
end

local function onClick(player, clickLocation)	
	createPart(clickLocation)
end

local function onEquip()
	clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
end


tool.Equipped:connect(onEquip)

7 comments

0

This entire script is all sorts of wacky

0

My friens wanted me to make a car spawner into a tool for his group. This is part of the script.

0

This is even worse,. Let me write you a whole new script.

0

wait, do you want the car to spawn where the player clicked or where the block is?

0

where the block is

0

I updated my solution because now I now just about everything iu need to know. I will test it out real quick to

0

I got it to work but the car needs to be reqelded after it's made. LIke its comletly anchored then welded the unanchored. Maybe you can figure out how to do that through a script though.

3 answers

This entire script is all sorts of wacky.

local work = game.Workspace --no, you can use workspace as its own now
local car = game.ReplicatedStorage.Assets.Car
car.Parent = work
car:MakeJoints() -- no, pointless if you try to move anything
work.Car:MoveTo(spawnblock.Position) --no, thi is only a humanoid object fuction
work.Car.Archivable = true --no, its already set to true
work.Car:Clone()
work.Car.Parent = game.ReplicatedStorage.Assets

No thats covered, my solution.

Get a welding plugin, I recommend Jojomen56's utility plugin, then weld the car to itself.

now myour new script

local tool = script.Parent
local spawnblock = game.Workspace.spawnblock

function createPart(location)
    local work = game.Workspace
    local car = game.ReplicatedStorage.Assets.Car
    car.Parent = work
    work.Car.basepart.Position = location --change basepart to watever the part is that everything is welded to
    work.Car:Clone().Parent = game.ReplicatedStorage.Assets
end


tool.Activated:connect(function()createPart(spawnblock.Position +Vector3.new(0,5,0))end) --to avoid colliding with anything, we put it a little above

Also be sure it's either in a hopper bin or a tool with handle disabled

1 comment

0

This works but the car can't move

You forgot to set a variable to the new cloned version.

local work = game.Workspace
local car = game.ReplicatedStorage.Assets.Car
car.Parent = work
car:MakeJoints()
work.Car:MoveTo(spawnblock.Position)
work.Car.Archivable = true
work.Car:Clone() --Need to set a variable to this
work.Car.Parent = game.ReplicatedStorage.Assets -- Referencing the old one still

local work = game.Workspace
local car = game.ReplicatedStorage.Assets.Car
car.Parent = work
car:MakeJoints()
work.Car:MoveTo(spawnblock.Position)
work.Car.Archivable = true
local newCar = work.Car:Clone()
newCar.Parent = game.ReplicatedStorage.Assets

--Also, work.car is a little off, it isn't referencing right. You already added car to the workspace and its still referencing the same object even if you changed the location of the object

local work = game.Workspace
local car = game.ReplicatedStorage.Assets.Car
car.Parent = work
car:MakeJoints()
car:MoveTo(spawnblock.Position) --removed work.car because of incorrect referencing.
car.Archivable = true
local newCar = car:Clone()
newCar.Parent = game.ReplicatedStorage.Assets

--The above script should now work. Be sure to let me know if anything is wrong in my script or you still can't get it to work. Also, mark this answer as correct if this solves your problem, the button should be right under my character image to the right.

2 comments

0

No he did, but what hes doingis pulling the car from storage then putting the clone into storage

0

This didn't do what I wanted it all to do

Remove line 8 and put this at line 7 work.Car:Clone().Parent = game.ReplicatedStorage.Assets

1 comment

0

That doesn't work

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