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.
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