I want a reliable way to detect a part touching another part. (That doesn’t stop firing if not moved like . Touched)
I tried using get touching parts but it broke and doesn’t do anything
.Touched has always infuriated me for just being unreliable and weird
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
while wait() do
if plr.Character:FindFirstChild("AttackHitBox") then
plr.Character:FindFirstChild("AttackHitBox").Touched:Connect(function(part)
if part:FindFirstChild("Destroyable") and plr:FindFirstChild("Punching") then
local Material = part.Material
local Color = part.Color
local Position = Vector3.new(part.Position.X + math.random(1,6),part.Position.Y + math.random(1,6),part.Position.Z + math.random(1,6))
part:Destroy()
for i = 1,4,1 do
local DebrisPart = Instance.new("Part")
DebrisPart.Size = Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2))
DebrisPart.Material = Material
DebrisPart.Color = Color
DebrisPart.Position = Position
DebrisPart.Parent = game.Workspace
fling(DebrisPart,plr.Character)
local DespawnClone = script.DespawnScript:Clone()
DespawnClone.Parent = DebrisPart
DespawnClone.Disabled = false
end
for index = 1,4,1 do
local CoinPart = Instance.new("Part")
CoinPart.Size = Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2))
CoinPart.Material = Enum.Material.Metal
CoinPart.Color = Color3.new(1, 1, 0)
CoinPart.Position = Position
CoinPart.Parent = game.Workspace
fling(CoinPart,plr.Character)
local DespawnClone = script.DespawnScript:Clone()
DespawnClone.Parent = CoinPart
DespawnClone.Disabled = false
end
end
end)
end
end
end)
end)
If you need more info ask!