.Touched event never fires

this might be a simple fix, but im stuck on this dumb bug, whenever i spawn the meteor, it works, it moves to the right direction and ye stuff like that but when someone touches it, does it fire? no. so whenever the fireball is touched, it dosent do anything, it just moves forward.

The part of the script(i will not reveal all as i dont want my scripts to be stolen):

--fireball
local fireballdebounce = false
local touchdeb = false
script.Parent.summonfireball.OnServerEvent:Connect(function()
	if not fireballdebounce then
		fireballdebounce = true
		local fireball = Instance.new("Part")
		fireball.BrickColor = BrickColor.new("New Yeller")
		fireball.Size = Vector3.new(2,2,2)
		fireball.Material = Enum.Material.Neon
		fireball.Position = script.Parent.Parent.HumanoidRootPart.Position + (script.Parent.Parent.Head.CFrame.LookVector) -- ok
		fireball.Parent = game.Workspace
		local vl= Instance.new("BodyVelocity")
		vl.Parent = fireball
		vl.Velocity = Vector3.new(script.Parent.Parent.HumanoidRootPart.CFrame.LookVector.X*50,0,script.Parent.Parent.HumanoidRootPart.CFrame.LookVector.Z*50)
		fireball.Name = "FireBall"
		fireball.CanTouch = true
		fireball.Anchored = false
		fireball.Touched:Connect(function(m)
			if not touchdeb then
				touchdeb = true
				m = m.Parent
				if m:IsA("Accessory") then
					m = m.Parent
				end
				if m:FindFirstChild("Humanoid") and not m == script.Parent.Parent then
					m.Humanoid:TakeDamage(25)
				end
				task.wait(0.5)
				touchdeb = false
			end
		end)
		script.Parent.Handle.glow.Material = Enum.Material.Plastic
		game:GetService("Debris"):AddItem(fireball,2)
		task.wait(6)
		script.Parent.Handle.glow.Material = Enum.Material.Neon
		fireballdebounce = false
	end
end)

thanks.

Pretty sure because its always marked as false.

1 Like

The character humanoid is parented in the model, not the part it touched.
Easy fix, try replacing it with this:

if m.Parent:FindFirstChild("Humanoid") and not m == script.Parent.Parent then

but i defined m as parent:

so its not gonna work anyway

Setting the part to its parent will not work, and may return errors. Try this script:

if not touchdeb then
	touchdeb = true
	if not m.Parent:IsA("Accessory") and m.Parent:FindFirstChild("Humanoid") then
		m.Humanoid:TakeDamage(25)
	end
	task.wait(0.5)
	touchdeb = false
end

It’s because the script won’t detect when it hits something cus the bodyforce.You can instead do region 3 and keep the body force. Heres an example script. Edit everything with your variables and such. Just remove the .Touched:

local Metor = script.Parent
local RegionStats = Region3.new(Metor.Position - Metor.Size/ 2 * 1.25, Metor.Position +Metor.Size / 2 * 1.25)
local Blacklist = OverlapParams.new()
Blacklist.FilterType = Enum.RaycastFilterType.Blacklist
Blacklist.FilterDescendantsInstances = Metor
local Hitbox = workspace:GetPartBoundsInBox(RegionStats.CFrame, RegionStats.Size, Blacklist)
for i,v in pairs(Hitbox) do
	--- paste the things in the .touched event here. 
end

before you make m the parent, you check if m is an accessory, but the part that would touch is a child of the Accessory.

I think you want: if m’s parent is an accessory, make m the parent’s parent.

And why? When I did it before it worked as it should.

When I used your module, the same thing happened

Yes, so it also fires when the accessory is hit, and to make it easier I made the m variable the parent

I’ll try to print when touched, if it does not print then @kinglol123468 is right

nvm, it was because of the deb variable, it wasnt in the onserverevent event so now its fixed, thanks to all of the people who tried to fix my script

1 Like

Why not just create a fire ball and close it into the game? Allows for more in depth customization and its a lot less code

can you elaborate on that? I couldn’t understand

Whoops I meant clone. If you design the fireball yourself and then put it in server storage you can just clone that into the game instead of instancing the fireball like you have been doing. Lot less code and allows you to customize and make the fireball look better

Personally it’s shouldn’t because the fireball is only made out of 1 part

Ya but you can make it look a lot better if you model it in blender persay and import it in. It also takes less code. Literally 3 lines instead of 7