I recently made a placement system for an upcoming game, but I cant figure it out completely. I have the placing done but I cant seem to figure out how to make it place blocks on the side of block. Here is the tool script (Local)

local Tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local Item = game:GetService("ReplicatedStorage"):FindFirstChild("Furniture").Dirt
local PlaceEvent = game:GetService("ReplicatedStorage"):FindFirstChild("Events").Place
local Equipped = false
local GridSize = 3

Tool.Equipped:Connect(function()
	Equipped = true
end)

Tool.Unequipped:Connect(function()
	Equipped = false
end)

Tool.Activated:Connect(function()
	if Equipped then
		local pos = CFrame.new((math.floor(mouse.Hit.p.X / GridSize) * GridSize) + 0.5,(math.floor(mouse.Hit.p.Y / GridSize) * GridSize) + 1.5,(math.floor(mouse.Hit.p.Z / GridSize) * GridSize) + 0.5)
		PlaceEvent:FireServer(Item,pos)
	end
end)

game:GetService("RunService").RenderStepped:Connect(function()
	if game.Workspace:FindFirstChild("Placing") then
		game.Workspace.Placing:Destroy()
	end
	if Equipped then
		local pos = CFrame.new((math.floor(mouse.Hit.p.X / GridSize) * GridSize) + 0.5,(math.floor(mouse.Hit.p.Y / GridSize) * GridSize) + 1.5,(math.floor(mouse.Hit.p.Z / GridSize) * GridSize) + 0.5)
		local clone = Item:Clone()
		clone.Parent = workspace
		clone.Name = "Placing"
		clone.Part.CanCollide = false
		clone.Part.Transparency = 0.5
		clone:SetPrimaryPartCFrame(pos)
	end
end)

And the server script

local PlaceEvent = game:GetService("ReplicatedStorage"):FindFirstChild("Events").Place

PlaceEvent.OnServerEvent:connect(function(plr,item,pos)
	local clone = item:Clone()
	clone.Parent = workspace
	clone.Name = "Placed"
	clone:SetPrimaryPartCFrame(pos)
end)

Placing works fine. Make a place and put this code in and see what I mean.

2 comments

0

Do you have an active uncopylocked place where we can test it, that way we don't need to add all the events and furniture?

0