Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a system so a player can build on there land?

Asked by 6 years ago

Think of pizza place or lumber tycoon,

The way you can place things where you want,

The way they snap to a grid,

How would I do something like this?

Thanks for reading this.

-slipperycat753

2 answers

Log in to vote
0
Answered by 6 years ago

Hello slipperycat753,

I am not going to write code for you seeing as you have no code to start with. But I'll give you a brief explanation on how such system works, seeing as I've been working on a similar system myself recently.

First off, you need to get your mouse, meaning that everything works from a LocalScript. The mouse has certain events. (Wiki page: )

From that point, you can assign a part's or model's position to be the mouse position. Make sure the position updates every time the mouse is moved. This is for the preview, so the player knows where the object will appear as soon as they press the mouse button.

Then you want to assign the mouse position to the part or model again but this time when the mouse button is pressed.

In order to snap the objects to a grid, you should round the mouse position. This can be done using two things:

math.floor() -- Rounds a number down to an integer
math.ceil() -- Rounds a number up to an integer

This system needs some implementation. With a little bit of curiosity, dedication and a sparkle of creativity, you should be able to do this!

Friendly regards,

DefaultAxis

Ad
Log in to vote
0
Answered by
phxtn 154
6 years ago

I dont think this is the type of question you should be asking here

Answer this question