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)
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
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.
Remove line 8 and put this at line 7 work.Car:Clone().Parent = game.ReplicatedStorage.Assets