I am trying to spawn a part infront of another part. The part that will spawn will have various sizes based on an intvalue. for example if I change the value to 1 then the part size would be (4, 5, (1 * 4)) if I change the value to 2 then it would be (4, 5, (2 * 4)) (I mutiply the intvalue by 4 because my game is based on 4x4 block that form into a grid) I got the size working but the problem is the gap between the spawn part and another main part, I want the gap between them to stay the same no matter how much the size of the spawn part would be. kinda like this
blue = main part
red = spawn part
When I tried it, it became like this
Intvalue = 1
The picture above is exactly what I wanted but when I change the intvalue to 2, this happens
as you can see, the size changed correctly but the position is not that accurate, I want the gap between then to stay the same like in the first one, but for this one its move to the front a bit.
Here’s my script
script.Parent.MouseClick:Connect(function()
if deb == false then
deb = true
local RangeValue = StatsFolder.Range.Value
local Range = (RangeValue * 4)
local offset = Vector3.new(0, 0, -Range)
local Hitbox = Instance.new("Part")
Hitbox.Size = Vector3.new(4, 5, Range)
Hitbox.CFrame = Char.CFrame * CFrame.new(offset)
Hitbox.Color = Color3.fromRGB(255, 50, 50)
Hitbox.Transparency = 0.75
Hitbox.Material = "SmoothPlastic"
Hitbox.Anchored = true
Hitbox.CanCollide = false
Hitbox.Parent = game.Workspace.Hitboxes
task.wait(0.5)
deb = false
Hitbox:Destroy()
end
end)
Anyways, if anyone got solutions please tell me in the replies, Thanks in advance!