Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

5 comments

0

Use CFrame.

0

Where?

0

bump

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) ???

0

BUMP

1 answer

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

1 comment

0

It does not work. :/

This discussion is preserved as it was. New answers, comments, and votes are closed.