I'm trying to make a build mode similar to BloxBurg in the terms of you can only build in your plot and I'm trying to make the script check to see if the part you have drag of is inside of another block which covers the plot but doesn't hit the outside border. I've asked this question a couple times and have not gotten a response please help!!!
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local mTarget
local Down
local canPlace = false
local function canPlaceCheckTrue(mTarget)
canPlace = true
end
local function canPlaceCheckFalse(mTarget)
canPlace = false
end
game.Workspace.InsideBorder.Touched:Connect(canPlaceCheckTrue)
game.Workspace.OutsideBorderOne.Touched:Connect(canPlaceCheckFalse)
game.Workspace.OutsideBorderTwo.Touched:Connect(canPlaceCheckFalse)
game.Workspace.OutsideBorderThree.Touched:Connect(canPlaceCheckFalse)
game.Workspace.OutsideBorderFour.Touched:Connect(canPlaceCheckFalse)
function clickObject()
if Mouse.Target ~= nil and canPlace == true then
mTarget = Mouse.Target
print(mTarget)
Mouse.TargetFilter = mTarget
print(Mouse.TargetFilter)
Down = true
end
end
Mouse.Button1Down:Connect(clickObject)
function mouseMove()
if Down and mTarget and Player.BuildMode.Value == true then
local posX, posY, posZ = Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z
posX = math.floor(posX / 2 + 0.5)*2
posY = posY + .5
posZ = math.floor(posZ / 2 + 0.5)*2
mTarget.Position = Vector3.new(posX, posY, posZ)
end
end
Mouse.Move:Connect(mouseMove)
function mouseDown()
Down = false
Mouse.Target = nil
Mouse.TargetFilter = nil
end
Mouse.Button1Up:Connect(mouseDown)
BTW I have tested it already and it lets you build but I can still place parts outside the plot's "check" box(InsideBorder)
