Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game.ReplicatedStorage:WaitForChild("PlaceFurnitureRE").OnServerEvent:Connect(function(plr, furniture, cframe, placing, plot)
- if placing then
- local pos = cframe.Position
- local lowerX, lowerZ = plot.Position.X - plot.Size.X/2, plot.Position.Z - plot.Size.Z/2
- local upperX, upperZ = plot.Position.X + plot.Size.X/2, plot.Position.Z + plot.Size.Z/2
- if pos.X < upperX and pos.X > lowerX and pos.Z < upperZ and pos.Z > lowerZ then
- local furnitureClone = furniture:Clone()
- furnitureClone:SetPrimaryPartCFrame(cframe)
- for i, d in pairs(furnitureClone:GetDescendants()) do
- if d:IsA("BasePart") then d.Transparency = 1; d.CanCollide = false end
- end
- furnitureClone.Parent = workspace
- furnitureClone.PrimaryPart.Touched:Connect(function()end)
- local touchingParts = furnitureClone.PrimaryPart:GetTouchingParts()
- for i, touchingPart in pairs(touchingParts) do
- if touchingPart.Name == "Hitbox" then furnitureClone:Destroy(); return end
- end
- for i, d in pairs(furnitureClone:GetDescendants()) do
- if d:IsA("BasePart") and d.Name ~= "Hitbox" and not d:IsA("Seat") then d.Transparency = 0; d.CanCollide = true end
- end
- end
- elseif furniture then
- if furniture.Parent.Parent:FindFirstChild("Hitbox") then furniture.Parent.Parent:Destroy() end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement