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

Why is this part going up but not going to the left?

Asked by 6 years ago

Here is my script that I have problems with:

MiningArea = script.Parent.Parent.Parent
PartPos = script.Parent.Position
function CClone(Xadd, Yadd, Zadd) --Function
    local part = game.Lighting.Block:Clone()
    part.Parent = MiningArea.Blocks
    part.Position = script.Parent.Position
    script.Parent.Position = Vector3.new(PartPos.X + Xadd, PartPos.Y + Yadd, PartPos.Z + Zadd)
    wait(0.01)
end


CClone(0, 5, 0) -- Goes up by 5

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 5, 0)

CClone(0, 0, -5) --This goes up for some reason!

I added comments that tell you things. Please help me ASAP.

0
Use CFrame. hiimgoodpack 2009 — 6y
0
Where? MrWafflesNBacon -1 — 6y
0
bump MrWafflesNBacon -1 — 6y
0
If this is just a problem concerning math, have you tried simply using  positive 5 instead on the Z value of the last line of your script, (0,0,5) ??? JoeRaptor 72 — 6y
0
BUMP MrWafflesNBacon -1 — 6y

1 answer

Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago

You define PartPos outside of the function, so it doesn't get updated.

Just define it inside the function.

function CClone(Xadd, Yadd, Zadd) --Function
    local PartPos = script.Parent.Position -- moved
    local part = game.Lighting.Block:Clone()
    part.Parent = MiningArea.Blocks
    part.Position = script.Parent.Position
    script.Parent.Position = Vector3.new(PartPos.X + Xadd, PartPos.Y + Yadd, PartPos.Z + Zadd)
    wait(0.01)
end

Also use local variables you savage

0
It does not work. :/ MrWafflesNBacon -1 — 6y
Ad

Answer this question