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.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local blankPart = Instance.new('Part') blankPart.Anchored=true blankPart.CanCollide=false blankPart.Transparency=0.75 while wait(0.5) do local part = blankPart:Clone() --never change the original part, only a clone part.Parent=workspace mouse.TargetFilter=part --ignore the clone while getting mouse position local moveConn moveConn = mouse.Move:connect(function() local p = mouse.Hit.p part.Position = Vector3.new(math.floor(p.X),math.ceil(p.Y),math.floor(p.Z)) --mouse position in whole numbers end) mouse.Button1Down:wait() --do not have to connect a click function :) moveConn:disconnect() --stop moving the clone part.CanCollide=true part.Transparency=0 end
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.
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
game.Players.PlayerAdded:Connect(function(plr) Instance.new('Folder', workspace.Blocks).Name = plr.Name end)
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.
local mouse = game.Players.LocalPlayer:GetMouse() local OriginalMousePosition = mouse.Hit.p local Active = false local tool = script.Parent tool.Equipped:Connect(function() Active = true end) tool.Unequipped:Connect(function() game.ReplicatedStorage.RemovePassive:FireServer() Active = false end) mouse.Button1Down:Connect(function() if Active then game.ReplicatedStorage.PlaceBlock:FireServer(mouse.Hit.p, false) --Bool value represents passive bool end end) while wait() do if Active then if OrginalMousePosition ~= mouse.Hit.p then OrginalMousePosition = mouse.Hit.p game.ReplicatedStorage.RemovePassive:FireServer() game.ReplicatedStorage.PlaceBlock:FireServer(mouse.Hit.p, true) --Bool value represents passive bool end end end
Here's what the server script in ServerScriptService would look like
local function IsInt(number) do if '.' in tostring(number) then return false else return true end local function NearestMultiple(number, multiple) --I think this function works number = math.floor(number) local newNum = number local count = 0 while not IsInt(testNum/multiple) do newNum = testNum - 1 count = count + 1 end if count <= multiple/2 then return newNum else return newNum + multiple end game.ReplicatedStorage.PlaceBlock.OnServerEvent:Connect(function(plr, pos, passive) BlockName = --Get name of block local block = game.ReplicatedStorage.Blocks[BlockName]:Clone() --A folder called Blocks in ReplicatedStorage that contains all the blocks local BlockSize = block.Size.X --I can grab one value if all the values of the size are the same local x = NearestMultiple(pos.X, BlockSize) --Rounding the positions will give it a more Minecraft aspect local y = NearestMultiple(pos.Y, BlockSize) local z = NearestMultiple(pos.Z, BlockSize) block.Position = Vector3.new(x + _, y + _, z + _) --I'll leave you to fill in the blank. You have to add something so it centers rather than half being in the ground. if passive then block.Transparency = 0.5 block.CanCollide = true block.Name = 'Passive' end block.Parent = workspace.Blocks[plr.Name] end)
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!
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'
local function IsInt(number) do if '.' in tostring(number) then return false else return true end
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?