Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

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

Asked by 8 years ago
Edited 8 years ago

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)
0
This entire script is all sorts of wacky rollercoaster57 65 — 8y
0
My friens wanted me to make a car spawner into a tool for his group. This is part of the script. MrMinecraft998887 87 — 8y
0
This is even worse,. Let me write you a whole new script. rollercoaster57 65 — 8y
0
wait, do you want the car to spawn where the player clicked or where the block is? rollercoaster57 65 — 8y
View all comments (3 more)
0
where the block is MrMinecraft998887 87 — 8y
0
I updated my solution because now I now just about everything iu need to know. I will test it out real quick to rollercoaster57 65 — 8y
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. rollercoaster57 65 — 8y

3 answers

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

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

0
This works but the car can't move MrMinecraft998887 87 — 8y
Ad
Log in to vote
1
Answered by 8 years ago

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.
0
No he did, but what hes doingis pulling the car from storage then putting the clone into storage rollercoaster57 65 — 8y
0
This didn't do what I wanted it all to do MrMinecraft998887 87 — 8y
Log in to vote
-1
Answered by 8 years ago

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

0
That doesn't work MrMinecraft998887 87 — 8y

Answer this question