Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local snap = 3
- game.ReplicatedStorage:WaitForChild("PlaceBlockRE").OnServerEvent:Connect(function(plr, blockType, target, targetSurface, removeOrPlace)
- if removeOrPlace == "placing" then
- local position
- if targetSurface == Enum.NormalId.Top then
- position = target.Position + Vector3.new(0, snap, 0)
- elseif targetSurface == Enum.NormalId.Bottom then
- position = target.Position - Vector3.new(0, snap, 0)
- elseif targetSurface == Enum.NormalId.Left then
- position = target.Position - Vector3.new(snap, 0, 0)
- elseif targetSurface == Enum.NormalId.Right then
- position = target.Position + Vector3.new(snap, 0, 0)
- elseif targetSurface == Enum.NormalId.Front then
- position = target.Position - Vector3.new(0, 0, snap)
- elseif targetSurface == Enum.NormalId.Back then
- position = target.Position + Vector3.new(0, 0, snap)
- end
- local blockInPos
- for i, d in pairs(workspace:GetDescendants()) do
- if d:IsA("BasePart") and d.Position == position then blockInPos = true end
- end
- if not blockInPos and position then
- local newBlock = blockType:Clone()
- newBlock.Size = Vector3.new(snap, snap, snap)
- newBlock.Anchored = true
- newBlock.Position = position
- newBlock.Parent = workspace
- game.ReplicatedStorage.PlaySoundRE:FireClient(plr)
- end
- elseif removeOrPlace == "removing" then
- if target and target:FindFirstChild("Placeable") then
- target:Destroy()
- game.ReplicatedStorage.PlaySoundRE:FireClient(plr)
- end
- end
- end)
- local gridX, gridZ = 100, 100
- for x = 1, gridX do
- for z = 1, gridZ do
- local block = game.ReplicatedStorage.Blocks.Grass:Clone()
- block.Size = Vector3.new(snap, snap, snap)
- block.Anchored = true
- block.Position = Vector3.new(snap * x, snap, snap * z)
- block.Parent = workspace
- end
- end
Add Comment
Please, Sign In to add comment