Free place placement system

I am looking to make a placement system but I don’t want a grid I really want players to have free placement abilities

I have tried to do tutorials and I keep getting errors. I have not found a free place building system tutorial that works currently.

FIRST SCRIPT

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local PlaceStructure = ReplicatedStorage:WaitForChild(“PlaceStructure”)

local UIS =game:GetService(“UserInputService”)
local Runservice = game:GetService(“RunService”)

local player = game.Players.LocalPlayer
local StructureFrame =script.Parent.StructureFrame
local char = player.Character or player.Character:Wait()
local HumanoidRootPart = char:WaitForChild(“HumanoidRootPart”)

local mouse = player:GetMouse()

local yBuildingOffset = 5
local maxPlacingDistance = 50
local rKeyIsPressed = false
local placingStructure = false

for _, structureButton in pairs(StructureFrame:GetChildren()) do
if structureButton: IsA(“TextButton”) then
structureButton.MouseButton1Up:Connect(function()

        structureFrame.Visible = false
        
        local yOrientation = 0
        local goodToPlace = false
        local placedStructure
        
        if placingStructure == false then
            placingStructure = true
            
            local clientStructure = Structures:FindFirstChild(structureButton.Name):Clone()
            clientStructure.BrickColor = BrickColor.new("Forest green")
            clientStructure.Material = "Neon"
            clientStructure.CanCollide = true
            clientStructure.Parent = game.Workspace
            
            local startingCFrame = CFrame.new0, -2, -15)
            clientStructure.CFrame = HumanoidRootPart.CFrame:ToWorldSpace(startingCFrame)

            RunService.RenderStepped:Connect(function()
                local mouseRay = mouse.UnitRay
                local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000)
                local ignoreList = (clientStructure, char)
                local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)
                
                if hit and (hit:IsA("terrain") or hit.Name:lower() == "terrain") and (HumanoidRootPart.Position - clientStructure.Position).Magnitude
                    goodToPlace = true
                    clientStructure.BrickColor = BrickColor.new("Forest green")
                else
                    goodToPlace = false
                    clientStructure.BrickColor = BrickColor.new("Crimson")
                end
                    
                local newAnglesCFrame = CFrame.Angles(0, math.rad(yOrientation), 0)
                local newCFrame = CFrame.new(position.X, position.Y + yBuildingOffset, position.Z)
                clientStructure.CFrame = newCFrame * newCFrame
            end)
            
            UIS.Input.Began:Connect(function(input)
                if input.KeyCode == Enum.KeyCode.R then
                    rKeyIsPressed = true
                    
                    local rotationSpeed = 5 
                    while rKeyIsPressed do 
                        wait()
                        if placingStructure == true then
                yOrientation - yOrientation + rotationSpeed
                        end
                    end
                end
            end)   
            
            UIS.InputEnded:Connect(function(input)
                if input.KeyCode == Enum.KeyCode.R then 
                    rKeyIsPressed = false
                end
            end)
            
            UIS.InputEnded:Connect(function(input)
                if input.KeyCode == Enum.UserInputType.MouseButton1 then
                    if placingStructure == true then
                        if goodToPlace == true then
                            local StructureCFrame = clientStructure.CFrame
                              placedStructure = PlaceStructure:InvokeServer(clientStructure.Name, Structure
                            if placedStructure == true then 
                                placingStructure = false
                                clientStructure:Destroy()
                                StructureFrame Visible = true
                            end
                        end
                    end
                end
            end)   
        end
    end)
end

end

SECOND SCRIPT

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)

local PlaceStructure = ReplicatedStorage:WaitForChild(“PlaceStructure”)

local Structures = ReplicatedStorage:WaitForChild(“Structures”)

PlaceStructure.OnServerInvoke = function(player, StructureName, StructureCFrame)

local crafted

local realStructure = Structures:FindFirstChild(StructureName) :Clone()

if realStructure then

    realStructure.CFrame = StructureCFrame

    realStructure.Parent = game.Workspace

    crafted = true

else

    crafted = false

end

return crafted

end

Tutorials video

Please if you can help either reply or message me on discord
Lothomost#2999

so maybe you’re new to scripting. But this message will assume you understand what i’m talking about.

So, it’s rather simple. You get the local player in a local script
local player = game.Players.LocalPlayer
then you get the mouse
local mouse = player:GetMouse()
then the mouse cframe is mouse.Hit, so you’re going to want to send that to the server.

then on the server,
OurCframe = CFrame.new(mousehit.Position)
we do this because, the mouse cframe has rotation.
these are the basics of free placement.

1 Like

I am fairly new but I will send this over to my scripter so he can attempt to implement it

Thanks @poprobertb6 sorry it took a while.