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

How do I create parts in a specific place with CFrame?

Asked by 6 years ago

So, I'm a newbie in this script stuff, and I made a few simple things. Currently I'm trying to understand CFrame and trying to make a dropper, but I will talk about the dropper. I'm trying to make a dropper with a few lines which I think it's the necessary. I took a look at a already done script to try understand it, but I'm having a problem with where the part is created(CFrame).

local dropperOre = Instance.new("Part",Workspace)

while true do
    dropperOre.CFrame = CFrame.new(Workspace.Part.Position, Vector3.new(-80, 10, 90))
    dropperOre.FormFactor = "Custom"
    dropperOre.Size = Vector3.new(1,1,1)
    wait(1)
end

Also, tell me if something is wrong or if the entire script is. Sorry if it is ridiculously wrong.

0
What exactly are you trying to do? Is it to make the ore fall naturally, with gravity, or to use CFrame to manually move it down? Also, the default CFrame, I believe is CFrame.new(), which is 0,0,0. The line of code on line 4 would make it keep its position, and look at -80,10,90. It should be CFrame.new(-80,10,90). UgOsMiLy 1074 — 6y
0
Oh, yes, I wanna make the part naturally fall. Thank you! Igroshbauli 2 — 6y

1 answer

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

This script actually looks okay. However, there is one thing that would cause this script to malfunction.

Inside the loop, you're changing the position of dropperOre, a part which gets created outside the loop. This means you only ever create a single ore to drop, and try to repeatably drop it inside the loop.

Simply place that part inside the loop.

while true do
    local dropperOre = Instance.new("Part")
    dropperOre.CFrame = CFrame.new(workspace.Part.Position, Vector3.new(-80, 10, 90))
    dropperOre.FormFactor = "Custom"
    dropperOre.Size = Vector3.new(1,1,1)
    dropperOre.Parent = workspace
    wait(1)
end
I also changed where the parent of the ore gets changed. It's best to set the parent last, and to use workspace when trying to access game.Workspace.

Also, as the comments say, you're using the CFrame constructor, CFrame.new(position, lookAt)

So make sure you're using the corrent position you want.

0
Ohh, thank you! Igroshbauli 2 — 6y
Ad

Answer this question