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

I need help on making a place block tool? [Need Snapping Fix]

Asked by 5 years ago
Edited 5 years ago

I made this, but it's not FE, and it works without holding the tool, which I don't want. I want to be able to make this customizable for like a minecraft game.

Not Trying To Request, But I just cant get it to work.

I could make the blocks myself but i cant get it to connect to a folder in ServerStorage.

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03local blankPart = Instance.new('Part')
04blankPart.Anchored=true
05blankPart.CanCollide=false
06blankPart.Transparency=0.75
07 
08while wait(0.5) do
09    local part = blankPart:Clone() --never change the original part, only a clone
10    part.Parent=workspace
11    mouse.TargetFilter=part --ignore the clone while getting mouse position
12    local moveConn
13    moveConn = mouse.Move:connect(function()
14        local p = mouse.Hit.p
15        part.Position = Vector3.new(math.floor(p.X),math.ceil(p.Y),math.floor(p.Z)) --mouse position in whole numbers
View all 21 lines...

Please help, thanks (I will accept your answer if it works!) Also, I know F3X Exists, but I don't want to use that for this game, so don't send me plugin or model links for that, or broken toolbox models.

2 answers

Log in to vote
1
Answered by
sheepposu 561 Moderation Voter
5 years ago
Edited 5 years ago

I actually achieved the result you are looking for recently so I can help you. First off, the blocks can go in Replicated storage. Next, for a Minecraft type game, you should make a folder in the workspace called "Blocks" and have a server script in ServerScriptService do the following

1game.Players.PlayerAdded:Connect(function(plr)
2    Instance.new('Folder', workspace.Blocks).Name = plr.Name
3end)

Then you can move all the blocks a player places into their folder which may come in handy later. You should get the mouse coords and everything and send it to a server script in ServerScriptService. If the block is placed from a LocalScript only the player who placed it will see the block. Also, if a localscript does all the math, it can be exploited by hackers. Here's a example of what your LocalScript might look like. I put a RemoteEvent in ReplicatedStorage called PlaceBlock. I also made another event called RemovePassive that will be used to remove passive blocks.

01local mouse = game.Players.LocalPlayer:GetMouse()
02local OriginalMousePosition = mouse.Hit.p
03local Active = false
04local tool = script.Parent
05 
06tool.Equipped:Connect(function()
07    Active = true
08end)
09 
10tool.Unequipped:Connect(function()
11    game.ReplicatedStorage.RemovePassive:FireServer()
12    Active = false
13end)
14 
15mouse.Button1Down:Connect(function()
View all 29 lines...

Here's what the server script in ServerScriptService would look like

01local function IsInt(number) do
02    if '.' in tostring(number) then return false else return true
03end
04 
05local function NearestMultiple(number, multiple) --I think this function works
06    number = math.floor(number)
07    local newNum = number
08    local count = 0
09    while not IsInt(testNum/multiple) do
10        newNum = testNum - 1
11        count = count + 1
12    end
13    if count <= multiple/2 then
14        return newNum
15    else
View all 33 lines...

It should look something like this You can do the RemovePassive script, but let me tell you to use a "pcall(function()" in it, for when it is fired without there being a passive block. Hope this helps!

0
Does not work, see my below answer for more RobloxGameingStudios 145 — 5y
0
I got it to function RobloxGameingStudios 145 — 5y
0
Check my answer's comments for more info, on things i cant get to wrok RobloxGameingStudios 145 — 5y
0
mostly solved my issue, can u please help me on getting the building transparent thing that follow mouse, so its in a cube like form RobloxGameingStudios 145 — 5y
View all comments (2 more)
0
Any errors. It's the same as placing a black, but it's name is Passive, it is 50% transparent, and can't collide sheepposu 561 — 5y
0
Any errors. It's the same as placing a block, but it's name is Passive, it is 50% transparent, and can't collide sheepposu 561 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You Fixed Most Of My Problems Through Comments, But I come across this error.

19:47:33.978 - ServerScriptService.New Server:2: 'then' expected near 'in'

1local function IsInt(number) do
2    if '.' in tostring(number) then return false else return true
3end

This code seems to be broken, Also I don't understand what u mean by if '.' in, what am i supposed to fill in there?

0
The fill in the blank was BlockSize/2. Any errors? sheepposu 561 — 5y
0
I have no auto clicker on. I checked. RobloxGameingStudios 145 — 5y
0
It also goes through other blocks. RobloxGameingStudios 145 — 5y
0
also can u make the delete script, i cant seem to get it. RobloxGameingStudios 145 — 5y
View all comments (33 more)
0
Delete Passive? sheepposu 561 — 5y
0
Or delete a placed block? sheepposu 561 — 5y
0
I have the delete script, I just cant understand how to get the blocks to snap like minecraft so they aren't going through other blocks RobloxGameingStudios 145 — 5y
0
Oh, When you round them, you have to round them to a multiple of the size of the block. For example if the block is 5x5x5, then it should be rounded to the nearest multiple of 5. Let me fix the script to do it sheepposu 561 — 5y
0
Now instead of using math.floor, use the new function I added on my answer sheepposu 561 — 5y
0
check my answer for update RobloxGameingStudios 145 — 5y
0
please answer, PLEASE SO MUCH RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
can u help RobloxGameingStudios 145 — 5y
0
oh my RobloxGameingStudios 145 — 5y
0
ScriptingHelpers.Org glitch it seems RobloxGameingStudios 145 — 5y

Answer this question