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)
~~~~~~~~~~~~~~~~~.
This question was answered in the comments I am just putting an answer down here for anyone who doesn't check the comments.
Set the part's size then set its CFrame.