bullet.Touched:Connect(function(hit)
task.wait(0.1)
bullet:Destroy()
if hit.Parent ~= player.Character then -- so localPlayer does not get damaged
if hit then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Name == "Head" then
hit.Parent:FindFirstChild("Humanoid"):takeDamage(headshot)
else
hit.Parent:FindFirstChild("Humanoid"):takeDamage(damage)
end
if hit.Parent:FindFirstChild("Part") then -- finds first child of hit
if hit.Name == "Water" then -- if Part's name is Water
local waterP = Instance.new("ParticleEmitter")
waterP.Parent = bullet
waterP.Texture = "http://www.roblox.com/asset/?id=129418678"
waterP.Size = 2
waterP.LightEmission = 1
waterP.LightInfluence = 1
waterP.Lifetime = 1
waterP.Rate = 20
waterP.Speed = 10
waterP.Drag = 4
task.wait(0.1)
waterP:Destroy()
end
end
for some reason, when the bullet touches the part, the WaterP instance isnât created. I have no idea why, but Iâll ask here.
The destruction runs before any of the if statements though. Not sure where your logic is coming from, but the destruction of the bullet will always come first in this situation.
Try adding some prints to check where the conditions are leading to false and not running. Putting the destroy after the conditions and creating the instance is the best option (I would still recommend turning the bullet invisible and anchoring it before the if statements and creation of the instance).
Looking at the conditions, does the water have a humanoid? Is the water supposed to have a part named âPartâ underneath its parent? Itâs kind of confusing how you put the conditions.