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

When i place a block by my place tool it will go above the block i clicked on?

Asked by
ARTEK22 135
8 years ago
Edited 8 years ago

So let's say im making a bridge and when i try to make it i make a staircase, is there any way to fix it?

What is excatly happening: https://www.youtube.com/watch?v=4tBcbtrY8aw&feature=youtu.be (the link is unlisted now, it was private)

What is the code of the place tool:

local mouse = game.Players.LocalPlayer:GetMouse()
    local Tool = script.Parent



Tool.Equipped:connect(function()
    mouse.Button1Down:connect(function()
        local location = mouse.Hit.p
        local part = Instance.new('Part')
    part.Size = Vector3.new(2, 1, 2)
    part.Parent = workspace
    part.Anchored = true
    part.Position = location
    end)
end)

1 answer

Log in to vote
1
Answered by
Netflixy 126
8 years ago
Edited 8 years ago

Positioning a part results in the part going on top of other parts. Simple fix: use CFrame I also changed mouse click to tool activated, as if the tool was equipped once, it would fire on every click after equipped once, even when not equipped.

local mouse = game.Players.LocalPlayer:GetMouse()
local Tool = script.Parent



Tool.Equipped:connect(function()
   Tool.Activated:connect(function()
        local location = CFrame.new(mouse.Hit.p)
        local part = Instance.new('Part')
        part.Size = Vector3.new(2, 1, 2)
        part.Parent = workspace
        part.Anchored = true
        part.CFrame = location
    end)
end)
Ad

Answer this question