I have this script inside a part:
`script.Parent.ClickDetector.MaxActivationDistance = 7
local script = script
script.Parent.ClickDetector.MouseClick:Connect(function(abc)
local newpart = Instance.new("Part",workspace)
newpart.Material = Enum.Material.Neon
local randomColor = math.random(1, 2)
if randomColor == 1 then
newpart.BrickColor = BrickColor.new("Bright blue")
else
newpart.BrickColor = BrickColor.new("Really red")
end
newpart.Size = Vector3.new(4,4,4)
newpart.Position = Vector3.new(math.random(1,30),4,math.random(1,30))
newpart.Anchored = false
local clickdetector = Instance.new("ClickDetector",newpart)
local newscript = Instance.new("Script",newpart)
-- Set the source of the new script
local source = script.Source
newscript.Source = source
end)`
The script is supposed to spawn a new part in a random location when clicked on the part.
Everything is going well, the Click detector is working well but what is causing the truble is this part of the script:
local newscript = Instance.new("Script",newpart) -- Set the source of the new script local source = script.Source newscript.Source = source
It is supposed to make a new script inside the newpart, the source of the script should be the same as the orignal part, but the script is being created and the source inside the newscript is empty.
** You are now Level 4! **