#Building system not working

1 messages · Page 1 of 1 (latest)

swift grove
#

I am trying to make a building system that places a block where I click on the map, but as you can see in the video, the building system doesn't work as expected. and I don't know what causes that.

#

script:

#
local players = game:GetService("Players")
local player = players.LocalPlayer
local mousePart = workspace:WaitForChild("MousePart")
local mouse = player:GetMouse()
local RN = game:GetService("RunService")
mousePart.Transparency = 0.5
mousePart.CanCollide = false
mouse.TargetFilter = mousePart
local x, y, z = mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z
local folder = Instance.new("Folder")
folder.Parent = workspace
folder.Name = player.Name .. "'s Folder"


RN.PreRender:Connect(function()
    local x, y, z = mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z
    if mouse.Target then
        mousePart.CFrame = CFrame.new(math.round(x) + 0.5, math.round(y) + 0.5, math.round(z) + 0.5)
    end
end)

mouse.Button1Down:Connect(function()
    if mouse.Target then
        local x, y, z = mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z
        local PPart = Instance.new("Part")
        PPart.Parent = folder
        PPart.Transparency = 0
        PPart.Name = "PlasticBlock"
        PPart.CanCollide = true
        PPart.Anchored = true
        PPart.Material = Enum.Material.Plastic
        PPart.Size = Vector3.new(1, 1, 1)
        PPart.CFrame= CFrame.new(math.round(x) + 0.5, math.round(y)+ 0.5, math.round(z) + 0.5)
    end
end)
brave nexus
#

stop adding the offset

#

Why you add it anyways?

#

(in the rounding off part)

swift grove