how would I implement a stack system to my placement system?
( there would be a button and if you press it you can stack objects on each other )
local function FireRay(cloneObject, groundType)
local mouseRay = mouse.UnitRay
local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 50)
local ignoreList = {cloneObject}
local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)
if cloneObject.Stackable.Value == false then
if hit and hit.Name == groundType then
if hit:FindFirstAncestorWhichIsA("StringValue") and placing then
if hit:FindFirstAncestorWhichIsA("StringValue").Value == player.Name then
cloneObject.Hitbox.SelectionBox:Destroy()
placeEvent:FireServer(mouse.Hit.Position, cloneObject.PrimaryPart.Orientation, cloneObject.Name, hit:FindFirstAncestorWhichIsA("StringValue"))
else
cloneObject.Hitbox.SelectionBox.Color3 = Color3.new(1, 0.396078, 0.396078)
print("Unable to place on strangers plot")
end
end
end
else
if cloneObject.Stackable.Value == true then
if hit and hit.Name == groundType then
if hit:FindFirstAncestorWhichIsA("StringValue") then
if hit:FindFirstAncestorWhichIsA("StringValue").Value == player.Name then
placeEvent:FireServer(mouse.Hit.Position, cloneObject.PrimaryPart.Orientation, cloneObject.Name)
else
cloneObject.Hitbox.SelectionBox.Color3 = Color3.new(1, 0.396078, 0.396078)
print("Unable to place on strangers plot")
end
end
end
end
end
local newAnglesCFrame = CFrame.Angles(0, math.rad(yOrientation), 0)
local newCFrame = CFrame.new(position.X, position.Y + yBuildingOffset, position.Z)
cloneObject.Base.CFrame = newCFrame * newAnglesCFrame
end