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

Is there a way to spawn a new brick with a script in it?

Asked by 6 years ago

I'm trying to make a dropper block that drops bricks with scripts in them. Could I use something that uses something like this?

p = Instance.new("Part")
p.Anchored = false
p.Position = Vector3.new(math.random(-500,500), 50, math.random(-500,500))
p.Size = Vector3.new(1,0.2,2)
p.Parent = game.workspace
p.BrickColor = BrickColor.new(37)
p.BackSurface = "SmoothNoOutlines"
p.BottomSurface = "SmoothNoOutlines"
p.FrontSurface = "SmoothNoOutlines"
p.LeftSurface = "SmoothNoOutlines"
p.RightSurface = "SmoothNoOutlines"
p.TopSurface = "SmoothNoOutlines"
wait()
0
You can most likely apply the script to the created object in the same script it was created in :) Can you provide the code you wish to put inside the created object? Goulstem 8144 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

Parent the clone script to your script that you typed above, and disable it.

After, just put:

local scriptclone = script:WaitForChild("ScriptNameHere"):Clone() -- change "ScriptNameHere" to name of script you want to clone inside the part.
scriptclone.Parent = p
scriptclone.Disabled = false
0
Makes sense! I will try it! sillsdog 9 — 6y
Ad

Answer this question