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

Problems with clone of a model in ReplicatedStorage?

Asked by 9 years ago

I have a button that, when clicked, clones a model from ReplicatedStorage. The clone follows the player's cursor and locks to a grid area. When a certain part of the model is clicked, it is locked into position and no longer follows the cursor.

01local mouse = game.Players.LocalPlayer:GetMouse()
02local testdesk = game.ReplicatedStorage.TestDesk:Clone()
03 
04game:GetService("UserInputService").InputBegan:connect(function(inputObject)
05    if inputObject.KeyCode == Enum.KeyCode.R and script.Parent.Rotate.Value == false then
06        script.Parent.Rotate.Value = true
07    elseif inputObject.KeyCode == Enum.KeyCode.R and script.Parent.Rotate.Value == true then
08        script.Parent.Rotate.Value = false --When R is pressed, the model is rotated
09    elseif inputObject.KeyCode == Enum.KeyCode.LeftShift or inputObject.KeyCode == Enum.KeyCode.RightShift then
10        script.Parent.Parent.Parent.Cancel.Visible = false
11        testdesk.Parent = nil
12        script.Parent.Parent.Parent.Active.Value = false
13    end --When Shift is pressed, the model disappears
14end)
15 
View all 65 lines...

Here's what the GUI and the model look like:

01ScreenGui
02    Active (A BoolValue)
03    Cancel (A TextButton)
04    ScrollingFrame
05        DeskButton
06            Rotate (A BoolValue)
07            Local Script
08TestDesk
09    A bunch of parts
10    Primary (A Part)

The problem here is that since the clone of the model is determined before any events occur, which means that only one clone of the model can exist at any given time. Eventually I will make a script that will allow the player to place multiple desks or other models, and this clone problem is going to make that impossible. How can I fix this without ruining my script?

0
That is simple. When the placing gets done, redo Line 2. Marios2 360 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

So basically when the player is done placing an item, clone the item again and allow them to place it again.

Ad

Answer this question