Vector Scripting Help

hi, so im currently making a sort of tycoon game, but i need it so that when you buy a new dropper if there is already a dropper in the space it moves a certain amount of space to the right so that they are not colliding, and i know how to set new positions with vectors but I’m not sure how you could add a new position depending on where the last one was, any help?

1 Like

Just move the new dropper to the right (from the centre of the conflicting dropper) by however many studs wide it is.
Just add this to the (assuming Z) axis and set that as the new dropper’s position.
Something like this, I’m not sure exactly what your code or droppers look like. I’m assuming that the droppers are models.

-- Get CFrame of conflicting dropper
originCFrame = conflictDropper.PrimaryPart.CFrame
-- Create a new CFrame to get the position for the new dropper
newDropperCFrame = CFrame.new(originCFrame.X, originCFrame.Y, originCFrame.Z + newDropper.Base.Size.Z)
-- Move the new dropper
newDropper:SetPrimaryPartCFrame(newDropperCFrame)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.