So basically I am spawning a block and trying to check if it is touching anything. But the block is never touching anything because it always spawns above where it should, unless the spawn isn't being blocked by another block.
Here is my code:
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.G then
local charge = Instance.new("Part")
charge.Parent = game.Workspace
local location = game.Players.LocalPlayer.Character.Torso.Position
charge.Position = Vector3.new (location.x, location.y, location.z + 3)
charge.Size = Vector3.new (2, 2, 2)
charge.Anchored = true
wait(1)
local touchingParts = charge:GetTouchingParts()
charge:Destroy()
for _, p in next, touchingParts do
print(p.Name)
p:Destroy()
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
~~~~~~~~~~~~~~~~~.

5 comments
Try setting the part's CFrame instead of it's position.
Didn't work.
CFrame will ignore other parts. There's no way that would not work unless you are giving it the wrong position.
Set it's size then it's CFrame, when you update it's size it sets the position again
Thank you TheOtakuLyfe! Setting its size then it's CFrame worked!