So I have tried to create a hitbox bigger than the ball but the hit detection is delayed. I am using a local script to launch the ball and to detect it being hit.
It works better if the ball goes slower.
I am trying to break the glass on hit by removing all the welds from the parts that have been hit.
The glass is unanchored.
local function removeAllWelds(part)
for i,v in ipairs(part:GetDescendants()) do
if v:IsA("WeldConstraint") then
v:Destroy()
end
end
end
local function Break(part)
print("hit")
removeAllWelds(part)
playSound(part)
end
for _, part in ipairs(Parts:GetDescendants()) do
if part:IsA("BasePart") then
part.Touched:Connect(function(hit)
local speed = (part.AssemblyLinearVelocity - hit.AssemblyLinearVelocity).Magnitude
if speed >= 8 then
Break(part)
end
end)
end
end
Bigger hitbox:
I don’t want the hitbox to be too big so I need help.
Oh i thought you are speaking about the marble but not the glass, my apology.
So basically you can do the breaking the glass stuff for the marble instead of the glass which are sorta of the same as what you’re doing with the script for the glass pieces
So uh, just make the marble detect what part it hits if it’s the glass pieces then break
Not entirely sure how this works but could you not detect when the ball hits something called Glass or whatever it is called.
Or if it only works with hitbox then could you not make the marble have its own enlarged hitbox that does not count towards anything other than interacting with other hitboxes?