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

I am having duplication problems. Why won't this script duplicate? [CLOSED]

Asked by 8 years ago
Edited 8 years ago

I am trying to make a tool that duplicates a model then moves the duplicate to Workspace. Here is what I have:

01local tool = script.Parent
02local clickEvent = tool.ClickEvent
03local spawnblock = game.Workspace.spawnblock
04local clickEventConnection
05 
06local function createPart(location)
07    local work = game.Workspace
08    local car = game.ReplicatedStorage.Assets.Car
09    local newCar = car:Clone()
10    car:Clone()
11    newCar.Name = "Car"
12    car.Parent = work
13    car:MakeJoints()
14    car:MoveTo(spawnblock.Position)
15    newCar.Parent = game.ReplicatedStorage.Assets
View all 24 lines...

Here is a local script with the rest of the code:

01local tool = script.Parent
02local player = game.Players.LocalPlayer
03local mouse = player:GetMouse()
04local clickEvent = tool.ClickEvent
05 
06local function onActivate()
07    local clickLocation = game.Workspace.spawnblock
08    clickEvent:FireServer(clickLocation)
09    tool:Remove()
10end
11 
12tool.Activated:connect(onActivate)
0
Turn archivable on! Bertox 159 — 8y

3 answers

Log in to vote
1
Answered by 8 years ago
01local tool = script.Parent
02local clickEvent = tool.ClickEvent
03local spawnblock = game.Workspace.spawnblock
04local clickEventConnection
05 
06local function createPart(location)
07    local car = game.ReplicatedStorage.Assets.Car
08    local newCar = car:Clone()
09    newCar.Name = "Car"
10    newCar.Parent = game.Workspace
11    newCar:MakeJoints()
12    newCar:MoveTo(spawnblock.Position)
13end
14 
15local function onClick(player, clickLocation)
View all 21 lines...

This should be it, :)

0
OMG THANK YOU SOOOOO MUCH MrMinecraft998887 87 — 8y
Ad
Log in to vote
0
Answered by
Bertox 159
8 years ago
Edited 8 years ago
01local tool = script.Parent
02local clickEvent = tool.ClickEvent
03local spawnblock = game.Workspace.spawnblock
04local clickEventConnection
05 
06local function createPart(location)
07    local work = game.Workspace
08    local car = game.ReplicatedStorage.Assets.Car:Clone() --Clone it instantly! It will already get cloned.
09    car.Parent = work
10    car:MakeJoints()
11    car:MoveTo(spawnblock.Position)
12    car.Archivable = true
13end
14 
15local function onClick(player, clickLocation)
View all 24 lines...
0
could you put that in a code block MrMinecraft998887 87 — 8y
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

The way I was able to fix it was by changing the method you are using to detect a click! A tool has an event called activated so if you connect that it seems to work fine!

01local tool = script.Parent
02local spawnblock = game.Workspace.spawnblock
03 
04local function createPart(location)
05    local work = game.Workspace
06    local car = game.ReplicatedStorage.Assets.Car:Clone()
07    car.Parent = work
08    car:MakeJoints()
09    car:MoveTo(spawnblock.Position)
10    car.Archivable = true
11end
12 
13local function onClick(player, clickLocation)
14    createPart(clickLocation)
15end
View all 22 lines...
0
I already have the activated done MrMinecraft998887 87 — 8y

Answer this question