I want to make it so you can only place a block in a certain area (playerPlot) but it doesn't check. How would I fix the script to check beforing placing the block?
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local mTarget
local Down
function clickObject()
if Mouse.Target ~= nil 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 game.Workspace.InsideBorder.Touched and not game.Workspace.OutsideBorderOne.Touched and not game.Workspace.OutsideBorderTwo.Touched and not game.Workspace.OutsideBorderThree.Touched and not game.Workspace.OutsideBorderFour.Touched 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)
