Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What's wrong with this script???

function onTouch()
	local Robux = Instance.new("Part")
	Robux.Name = "Robuck"
	Robux.BrickColor = BrickColor.new("Bright green")
	Robux.Size = Vector3.new(1, 0.4, 2)
	Robux.TopSurface = "Smooth"
	Robux.BottomSurface = "Smooth"
	Robux.Position = game.Workspace.SpawnPart.Position
end
game.Workspace.Button.Touched:connect(onTouch)

4 comments

0

spawn a new brick

0

What is "SpawnPart"? Is it the same size as the new Part you are intending to create?

0

Well, BrickColor = BrickColor.new won't work, try Robux.BrickColor = Color3.new(0,0,255) and erase 'local'

0

The BrickColor.new("Bright green") is completely vaild. Erasing local will not help in this situation. What will help is any information on what happens and if there is any output.

2 answers

function onTouch()
    Robux = Instance.new("Part")
    Robux.Name = "Robuck"
    Robux.BrickColor = BrickColor.new(0,0,255)
    Robux.Size = Vector3.new(1, 0.4, 2)
    Robux.TopSurface = "Smooth"
    Robux.BottomSurface = "Smooth"
    Robux.CFrame = game.Workspace.SpawnPart.CFrame
end
game.Workspace.Button.Touched:connect(onTouch)

You have to say where to spawn it,

Like this:

function onTouch()
    local Robux = Instance.new("Part")
    Robux.Name = "Robuck"
    Robuck.Parent=game.Workspace
    Robux.BrickColor = BrickColor.new("Bright green")
    Robux.Size = Vector3.new(1, 0.4, 2)
    Robux.TopSurface = "Smooth"
    Robux.BottomSurface = "Smooth"
    Robux.Position = game.Workspace.SpawnPart.Position
end
game.Workspace.Button.Touched:connect(onTouch)

For line 08 you CAN do

Robuck.Position=Parent.SpawnPart.Position

I THINK that should solve you problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.