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

Instance.new Part Custom Cframe Value?

Asked by 6 years ago

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!

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
So what is allowNew? And what's peggy, i'm new can you explain these? Is peggy what the part will be named? FlippinAwesomeCrew 62 — 6y
0
why not put the wait after you create the part Vulkarin 581 — 6y
0
You don't need a bool value, just a variable after you define the click detector.(bool variable so you can't spam parts) DatOneRandomDude 69 — 6y
0
No, peggy is not the part that will be named. Peggy is just a variable for the instancing function so that on line 9, I can set the position. allowNew is a bool value to prevent spam you don't need a physical object just make a bool var. @Vulk I did put a wait. TheLightningRises 56 — 6y
0
Ok, thanks! FlippinAwesomeCrew 62 — 6y
Ad

Answer this question