So I'm making a game, and I want to have a button that spawns parts? What would I do to customize the part, make a different transparency,meterial,etc. Most importantly though how would I make a custom Cframe, or Vector3 value? Here's the script:
local clickdetector = script.Parent:WaitForChild("ClickDetector") clickdetector.MouseClick:Connect(function() local part = Instance.new("Part",game.Workspace) end)
Hope you can help, thanks!
Well, you shouldn't do it like that.
Here is a example.
local button = script.Parent local allowNew = script.Parent.BoolValue button.ClickDetector.MouseButton1Click:connect(function() if allowNew then allowNew = false wait(.1) peggy = instance.new("Part" , workspace) peggy.Cframe = Cframe.new(0,0,0) -- change Cframe values for specific position allowNew = true end)
This should work, try it out.
You also wanted transparency and color right? Well that's why you have peggy
.
Here is an updated for your transparency and color or even material.
local button = script.Parent local allowNew = script.Parent.BoolValue button.ClickDetector.MouseButton1Click:connect(function() if allowNew then allowNew = false wait(.1) peggy = instance.new("Part" , workspace) peggy.Cframe = Cframe.new(0,0,0) -- change Cframe values for specific position peggy.Transparency = 0.5 peggy.BrickColor = BrickColor.new("Really red") peggy.Material = Enum.Material.wood allowNew = true end)