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

How do I make a clone of a part run a script?

Asked by
trecept 367 Moderation Voter
6 years ago

I have a script inside a part in the server storage where it checks for when it's parent is changed, and if the parent is the workspace it explodes. But whenever I clone the part and parent it to the workspace, it wont explode or do anything, the script doesn't run properly.

local part1 = game.ServerStorage:FindFirstChild("Part"):Clone()
part1.Parent = game:GetService("Workspace")

Do scripts in cloned parts work?

0
first of all, instead of game:GetService("Workspace") write workspace NsNidPL 41 — 6y
0
maybe disable the script when it's inside serverstorage and enable it after you clone it? NsNidPL 41 — 6y
0
The same thing happens, the part goes into the workspace and does nothing the script tell it to do trecept 367 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

print("Hello trecept!")

I believe I know the answer to your problem.

The problem first of all, is I would need to see all of the code to figure out what happens.

The second problem is, which happened to me a lot, is calling the initial clone. You shouldn't make a variable to have a clone call.

local part1 = game.ServerStorage.Part

part1:Clone().Parent = workspace

Note the above named "Part" should be named what ever your part is named during the initial grabbing of the part :P

What the variable states, is the location of the part in server storage, and the :Clone() line also states the parent of the part.

Now just in case that doesn't work(Which it should, I have tested it in Roblox Studio), you can try using RemoteEvents. Which allow you to connect code to another parts of code, whenever the event is fired. For a quick run down on how remote Events works, let's say I have this script:

local hi = workspace.Camera
local event = game.ReplicatedStorage.hiEvent

(Note that this script is server side, more detail on that) To cast that event, I would just put:

event:FireClient(argument/variable)

To receive that event, you would need a local script stating a variable of the event

local event = game.ReplicatedStorage.hiEvent

event.OnServerEvent:Connect(function(parameter/arguement)
print("hi")
end)

Now only use Remote events if the cloning doesn't work.

If you need more assistants with this, be sure to ping me on social media(preferable discord) so I can continue with this problem!

Hope this helps!

Good luck and script on!;

Aspiring developer: Creep(Creeperthekid32)

Discord: Creep#7611 Twitter: @creeperthekid32 Roblox: Creeperthekid32

0
If there any mistakes, please feel free to correct me! Creeperthekid32 70 — 6y
Ad

Answer this question