Hello, I have a placement script which i can give to you… It’s not very complex but it can be easily expanded if you plan to have additional features in your system… i have not run into any problems with GetTouchingParts() with this script
local Mouse = game:GetService("Players").LocalPlayer:GetMouse()
local Block = game.Workspace.Block -- Block is the object to be placed, change it to whatever you like in the main script
local UserInputService = game:GetService("UserInputService")
local function GetChildrenWithName (object, name)
local table = object:GetChildren
local results = {}
for i,v in pairs (table) do
if v.Name == name then
table.insert (results,v)
end
return results
local Bases = GetChildrenWithName (game.Workspace , "Base") --"Base" is the name of part on which players will place the object
Mouse.TargetFilter = game.Workspace.Block
while true do
for i, v in pairs (Bases) do
if Mouse.Target == v then
local GridSize =1
local X = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize
local Z = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize
Block.Position = Vector3.new(X,Block.Position.Y,Z)
local function GetTouchingParts(part) --this is needed because my script uses parts with CanCollide disabled; if you want to use it on parts with CanCollide enabled then pls skip this part
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
local Collisions = GetTouchingParts(Block)
print(#Collisions)
local TouchingBounds = table.find(Collisions,game.Workspace.Bounds)
if TouchingBounds then
game.Players.LocalPlayer.PlayerGui.Placer.TextLabel.Text = "Can't Place here"
game.Players.LocalPlayer.PlayerGui.Placer.TextLabel.Visible = true
else
game.Players.LocalPlayer.PlayerGui.Placer.TextLabel.Visible = false
UserInputService.InputBegan:Connect(function(input,gameprocessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
game.ReplicatedStorage.PlacingEvent:FireServer(Vector3.new(Block.Position))
end
end
end)
end
end
end
wait(0.01)
end
Note: I know this script is very messy; it’s because I made this in a hurry, pls understand.