Explosion with :GetTouchingParts()

I’m trying to make splash damage with :GetTouchingParts()

The reason why I’m not using explosion.Hit is because :GetTouchingParts() is slightly more precise

(explosion.Hit get the part from its position, which is in the center of the part, and see if the part’s position is in the blast radius,
:GetTouchingParts() get parts that touch it, even if it’s just a little part of a corner)

Actually I don’t know if this is the case or not

local Hit = Splash:GetTouchingParts()

	for i,v in pairs(Hit) do
		if v.Parent:IsA("Model") then
			print(v)
		end
	end

--[[The explosion hits 2 objects, "Tank" and a "Soldier" model and it should
outputs the name of those 2]]

It does work but this is all it outputs, which is just the thing creating the explosion and its not even in a model so I don’t know how it get that
WIEGDUSBEDHDHDDU

Any help is appreciated
Sorry if I got something wrong

1 Like

Are you checking for touching parts before you resize the splash object?

2 Likes
function Explosion()
	local Splash = game.ReplicatedStorage.Splash:Clone()
	Splash.Parent = game.Workspace
	Splash.CFrame = script.Parent.CFrame
	
	local TweenService = game:GetService("TweenService")

	local Goal = {}
	Goal.Size = Vector3.new(script.Parent.SplashRadius.Value, script.Parent.SplashRadius.Value, script.Parent.SplashRadius.Value)
	Goal.Transparency = 0.9

	local Info = TweenInfo.new(1)

	local Tween = TweenService:Create(Splash, Info, Goal)

	Tween:Play()
	
	wait(1)
	
	local Hit = Splash:GetTouchingParts()

	for i,v in pairs(Hit) do
		if v.Parent:IsA("Model") then
			print(v)
		end
	end
end

I put wait(1) there with the TweenInfo

I don’t know the properties for the Splash object, but that could be the root of the problem. According to the documentation, if you set the part’s CanCollide value to false, then GetTouchingParts() won’t return anything. You could enable the CanCollide property or even use the GetPartsInPart() function instead, which is recommended by the documentation.

Documentation for GetTouchingParts()

1 Like