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

Why does it keep making a block but the body force only works in the first block?

Asked by 9 years ago

I used a tycoon starter kit, and then i altered the dropper, so that instead of falling, the blocks fly upwards! It works fine, on the first one. All of the blocks after the first one just fall but the first block works just fine!!! why is that so?!?!? Here is the script

function fire()
    local p = Instance.new("Part")
    p.Position = script.Parent.Position
    p.Size = Vector3.new(1,1,1) --size if u know how this works then delete the --'s at the start
    p.BrickColor = BrickColor.new(194) --color, see the roblox lua documentation if u know how this works then delete the --'s
    p.BottomSurface = 0
    p.TopSurface = 0
    p.Name = "TycoonBrick" --If you change this, make sure you change the name in the get script too (in the collect profits model)
    p.Parent = script.Parent
--start of my part
    local bf = Instance.new("BodyForce")
    bf.force = Vector3.new(0,250,0)
    bf.Parent = script.Parent.TycoonBrick
end 
--end of my part

while true do
    wait(script.Parent.Parent.SpeedValue.Value) --Alter Rate Of Drop
    fire()
end
--made by burnsy13
0
For the part color, you can find more colors here: http://wiki.roblox.com/index.php?title=BrickColor_Codes. According to this list, your tycoon parts will be medium stone grey/gray. EzraNehemiah_TF2 3552 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

At line 13, you're parenting the BodyForce to the first TycoonBrick it finds in the script's parent. Parent it to p instead:

function fire()
    local p = Instance.new("Part")
    p.Position = script.Parent.Position
    p.Size = Vector3.new(1,1,1) --size if u know how this works then delete the --'s at the start
    p.BrickColor = BrickColor.new(194) --color, see the roblox lua documentation if u know how this works then delete the --'s
    p.BottomSurface = 0
    p.TopSurface = 0
    p.Name = "TycoonBrick" --If you change this, make sure you change the name in the get script too (in the collect profits model)
    p.Parent = script.Parent
--start of my part
    local bf = Instance.new("BodyForce")
    bf.force = Vector3.new(0,250,0)
    bf.Parent = p
end 
--end of my part

while true do
wait(script.Parent.Parent.SpeedValue.Value) --Alter Rate Of Drop
fire()
end
--made by burnsy13

0
Well then the first part will not float. So there will be a part just lying on the ground the whole game. I know you're trying to help people but your scripts don't always work. EzraNehemiah_TF2 3552 — 9y
1
No, his code is correct. Perci1 4988 — 9y
1
What do you mean? Why wouldn't it float? It's being parented to p, Which is the part spawned in the function. It should work perfectly. aquathorn321 858 — 9y
0
@ Perci1 , What I'm trying to say is that there is still a part in the game named "TycoonBrick" which is in the model. Since he didn't make the body position's parent be both "p" and "TycoonBrick" there is going to be 1 part left in the tycoon money area. EzraNehemiah_TF2 3552 — 9y
View all comments (3 more)
0
@ Perci1 , Also, I'm not talking about this script. This script is fine. The reason I commented about this on this answer is because he isn't reading what I commented on this answer: https://scriptinghelpers.org/questions/15937/car-shop-gui-buy-button-not-workingsolved#19103 EzraNehemiah_TF2 3552 — 9y
1
p is the part spawned. You then parent the BodyForce to p, so the part spawned will float. This is correct. Perci1 4988 — 9y
0
What ARE you talking about? You commented on this script saying it wouldn't work, and now you're saying you weren't talking about this script? Besides, I already fixed my answer on the other script before answering this question. Why don't you just contact me directly instead of following me around commenting on my answers to get my attention? aquathorn321 858 — 9y
Ad
Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Your problem is

bf.Parent = script.Parent.TycoonBrick

You set the BodyForce's Parent to "TycoonBrick", but you're naming every part "TycoonBrick". After the first one is created, how do you know which "TycoonBrick" the script will choose? After all, there are multiple Parts with the same name.

You already have the variable equal to the current Part (p), so just use it.

local bf = Instance.new("BodyForce")
bf.force = Vector3.new(0,250,0)
bf.Parent = p

However, you should shorten this by using the second argument of Instance.new.

local bf = Instance.new("BodyForce", p)
bf.force = Vector3.new(0,250,0)

Answer this question