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.
01 | local tool = script.Parent |
02 | local clickEvent = tool.ClickEvent |
03 | local spawnblock = game.Workspace.spawnblock |
04 | local clickEventConnection |
05 |
06 | local function createPart(location) |
07 | local work = game.Workspace |
08 | local car = game.ReplicatedStorage.Assets.Car |
09 | car.Parent = work |
10 | car:MakeJoints() |
11 | work.Car:MoveTo(spawnblock.Position) |
12 | work.Car.Archivable = true |
13 | work.Car:Clone().Parent = game.ReplicatedStorage.Assets |
14 | end |
15 |
This entire script is all sorts of wacky.
1 | local work = game.Workspace --no, you can use workspace as its own now |
2 | local car = game.ReplicatedStorage.Assets.Car |
3 | car.Parent = work |
4 | car:MakeJoints() -- no, pointless if you try to move anything |
5 | work.Car:MoveTo(spawnblock.Position) --no, thi is only a humanoid object fuction |
6 | work.Car.Archivable = true --no, its already set to true |
7 | work.Car:Clone() |
8 | 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
01 | local tool = script.Parent |
02 | local spawnblock = game.Workspace.spawnblock |
03 |
04 | function createPart(location) |
05 | local work = game.Workspace |
06 | local car = game.ReplicatedStorage.Assets.Car |
07 | car.Parent = work |
08 | work.Car.basepart.Position = location --change basepart to watever the part is that everything is welded to |
09 | work.Car:Clone().Parent = game.ReplicatedStorage.Assets |
10 | end |
11 |
12 |
13 | tool.Activated:connect( function ()createPart(spawnblock.Position +Vector 3. 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
You forgot to set a variable to the new cloned version.
01 | local work = game.Workspace |
02 | local car = game.ReplicatedStorage.Assets.Car |
03 | car.Parent = work |
04 | car:MakeJoints() |
05 | work.Car:MoveTo(spawnblock.Position) |
06 | work.Car.Archivable = true |
07 | work.Car:Clone() --Need to set a variable to this |
08 | work.Car.Parent = game.ReplicatedStorage.Assets -- Referencing the old one still |
09 |
10 | local work = game.Workspace |
11 | local car = game.ReplicatedStorage.Assets.Car |
12 | car.Parent = work |
13 | car:MakeJoints() |
14 | work.Car:MoveTo(spawnblock.Position) |
15 | work.Car.Archivable = true |
Remove line 8 and put this at line 7 work.Car:Clone().Parent = game.ReplicatedStorage.Assets