i’m trying to code a hardpoint system for my game, so when a player is inside the hardpoint the hardpoint integrity changes. but when i use GetTouchingParts() for the code, it doesn’t seem to detect the player but only when the hitbox’s CanCollide property is set to true
how do i go with creating a hitbox that detects any players inside it?
runservice.Heartbeat:Connect(function(dt)
hardpointtable[v.Name].insurgents = {}
hardpointtable[v.Name].stf = {}
local partstouching = v.Hitbox:GetTouchingParts()
print(partstouching)
for i, v2 in pairs(partstouching) do
if v2 == "Terrain" then return end
local humanoid = v2.Parent:FindFirstChildOfClass("Humanoid")
print("Pass 3")
Simple solutions: Touch events, region3, :gettouchingparts(), :getpartboundsinbox()
a bit advanced: raycast with attachments
this is for detecting, now making the hitbox depends
if u want a simple hitbox u can create a new part instance and position it to the lookvector of the hrp, and weld them together, and detect if that part was touched by a player
else if u want a more accurate one you can use raycast