I have a building system and when the bottom block gets destroyed in a tower, i want it to fall over. I got all the parts to connect but when i break the bottom block that is holding them up they all Un-weld from eachother and are their own individual blocks. How can I fix this?
handling:
remote.OnServerEvent:Connect(function(plr, pos, part, name)
if game.ServerStorage.Stats.Build.Value == true then
if (plr.Character.HumanoidRootPart.Position - pos).Magnitude <= 51 and workspace.Cooldown:FindFirstChild(plr.Name) == nil and pos.Y <= 120 then
if pos.X <= 115 and pos.X >= -148 and pos.Z >= -120 and pos.Z <= 145 then
local p = game.ReplicatedStorage.Blocks:FindFirstChild(name):Clone()
p.Position = pos
p.Parent = workspace.PlacedBlocks
if part ~= nil then
local nweld = Instance.new("WeldConstraint")
nweld.Parent = p
nweld.Part1 = p
nweld.Part0 = part
p.Anchored = false
end
end
end
end
end)
local:
repeat wait(.1) until game:IsLoaded()
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local remote = game.ReplicatedStorage.Remotes.Place
local rbs = workspace.ReplicatedBlocks
local guil = plr.PlayerGui.PlacementUI
local camera = workspace.Camera
script.Parent.Equipped:Connect(function()
local gui = plr.PlayerGui
gui.PlacementUI.Enabled = true
end)
script.Parent.Unequipped:Connect(function()
local gui = plr.PlayerGui
gui.PlacementUI.Enabled = false
end)
script.Parent.Activated:Connect(function()
local gui = plr.PlayerGui.PlacementUI
if gui.Selected.Value == "delete" then
local unitray = camera:ScreenPointToRay(mouse.x, mouse.y, 0)
local ray = Ray.new(unitray.Origin, unitray.Direction * 200)
local target, position = workspace:FindPartOnRayWithIgnoreList(ray, {plr.Character, workspace.ReplicatedBlocks})
game.ReplicatedStorage.Remotes.Delete:FireServer(target)
else
if workspace.ReplicatedBlocks:GetChildren()[1]:FindFirstChild("toweld") ~= nil then
remote:FireServer(workspace.ReplicatedBlocks:GetChildren()[1].Position, workspace.ReplicatedBlocks:GetChildren()[1].toweld.Value, gui.Selected.Value)
else
remote:FireServer(workspace.ReplicatedBlocks:GetChildren()[1].Position, nil, gui.Selected.Value)
end
end
end)
