Creating A Furniture Placement System

It would be great if I understood it all :frowning: Still have a lot to learn

4 Likes

What I’m wondering is am I able to make the model first or do I have to script the model in? (I don’t understand a lot about scripting, sorry-)

1 Like

EgoMoose, do you know how you can add multiple canvases? That would be boss. Thanks for the tutorial!

2 Likes

@EgoMoose Is there a way to make the placement system work on Union canvases? Here’s a screenshot of what I mean:

1 Like

Can you help me out? Is there a way to not let clients change the GridUnit?

1 Like

I’d just recommend sticking to multiple parts instead of unions.

5 Likes

Wow, this was a ideal way of showing someone how to go about creating a proper placement system.

2 Likes

How would i be able to use multiple parts?

2 Likes

Apologies for the late response,

Please seek this post https://devforum.roblox.com/t/creating-a-furniture-placement-system/205509/26?u=coconutmangoes.

3 Likes

Thank you so much! (30 charss)

1 Like

Perhaps you have not enabled api services.

In order to enable api services, head on over to “Game Settings” in the top bar

Click on it, then go to “Options” and turn on API services

Hope this helps. :smiley:

2 Likes

On the server you can do the same thing the client does to force the object onto a grid.

I’m a bit late to this, but great guide! I learned a lot from it. Maybe you can give an explanation on how people should to this with multiple players thus more canvasses.

2 Likes

Thanks for this tutorial! I was able to put this together with what I learned here, complete with loading from a serialized copy. Going to be using this system in a new game I’m working on :smile:

External Media
4 Likes

So I’m implementing this into my own game, and there’s a problem. Mousebutton1Down and clickdetectors do not work. I’m pretty sure this is an issue on the client-side.
I’ll try to fix it, but an explanation on how to fix it would be great!

2 Likes

It’s the bind to action thing.

2 Likes

The context actions are really just a guide on how to handle user input for calling the different methods in the module. I suggest coming up with a solution of your own that handles input specific to your game.

1 Like

Great resource! I was reading the tutorial again recently and had a question. Would it be possible to modify this to allow for it to be used to block placement? What I mean by this is allowing the items to stack.

Hello! I’m RazorBladedino117, a scripter! I really enjoyed the tutorial, and have been using it to develop a system of my own! I’m having a bit of trouble with the system. My system is a bit different, and I’m not too experienced with OOP, so I ended up using functions instead. They do work similiarly but in general, it is quite a bit different in terms of how I organize my data. Could you help me? Reach out to me @RazorBladedino117#5440 on Discord!

Problems:

  • Orienting(Rotating) to fit the rotation of the plot
  • Grid System / Math to Calculate Positioning, and CFrame

Thanks! It would really help me improve if you could help me out :slight_smile: . Let me know what you think!

Code:

function CalculatePlacement(Position)
	local PlayerStats = Player.Stats
	local PlayerPlot = PlayerStats.Plot
	if PlayerPlot.Value ~= 0 then
		local Canvas = nil
		for _, Plot in pairs(PlotFolder:GetChildren()) do
			local PlotNumber = Plot.PlotNumber
			if PlotNumber.Value == PlayerPlot.Value then
				Canvas = Plot
			end
		end
		if Canvas ~= nil then	
			if not Workspace:FindFirstChild("Debris") then
				local DebrisFolder = Instance.new("Folder")
				DebrisFolder.Name = "Debris"
				DebrisFolder.Parent = Workspace
			end
	
			for _, x in pairs(Workspace.Debris:GetChildren()) do
				x:Destroy()
			end
		
		
			local CanvasCFrame = Canvas.CFrame
			local CanvasSize = Vector2.new(Canvas.Size.x, Canvas.Size.z)
	
			local Entity = Instance.new("Part")
			Entity.Size = InstanceData.Size	
	
			local EntitySize = CFrame.fromEulerAnglesXYZ(0, Rotation, 0) * Entity.Size
			EntitySize = Vector3.new(math.abs(EntitySize.x), math.abs(EntitySize.y), math.abs(EntitySize.z))
			Entity.Size = EntitySize
			
			local Size2 = (CanvasSize - Vector2.new(InstanceData.Size.z, InstanceData.Size.y))/2
			local LPos = CanvasCFrame:pointToObjectSpace(Position)
			
			local x = math.clamp(LPos.x, -Size2.x, Size2.x);
			local y = math.clamp(LPos.y, -Size2.y, Size2.y);
			
			Entity.Color = InstanceData.Color
			Entity.Transparency = InstanceData.Transparency
			Entity.Anchored = true
			
			local EntityCFrame = CanvasCFrame * CFrame.new(x,  -EntitySize.y/2, y) * CFrame.Angles(-math.pi/2, Rotation, 0)
			
			Entity.CFrame = EntityCFrame
			Entity.Parent = Workspace.Debris
		end	
	end
end

As you can probably tell, I’ve been trying to replicate bits of your code where I can, because I am stuck. The Math may end up being entirely different, due to the way your system is set up vs. mine. If you would like, I can TC you the game later on. Thanks!

P.S This function is currently on clientside, but after I figure out the math, I will impliment it to the actual placement system.

3 Likes

How do I assign placement.new() from the server instead of the player invoking the server to assign.