Part touched not working

  1. What do you want to achieve? Keep it simple and clear!

A bomb that explode and it’s also explode when player touch too

  1. What is the issue? Include screenshots / videos if possible!

the touch is not working

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Tried looking for solution but don’t know

here is the script for the explode part

script.Parent.OnServerEvent:Connect(function(p)
	local character = p.Character
	local humrp = character:WaitForChild("HumanoidRootPart")
	local hum = character:WaitForChild("Humanoid")
	local offset = Vector3.new(0,-2.5,-2.5)
	local animtrack = hum:LoadAnimation(script.Parent.Parent:WaitForChild("LocalScript"):WaitForChild("Animation"))
	local sound = script.Parent.Parent:WaitForChild("Handle"):WaitForChild("Select")
	
	if character:FindFirstChild("Bomb") == nil then
		animtrack:Play()
		sound:Play()
		local Clone = bomb:Clone()
		Clone.CFrame = humrp.CFrame*CFrame.new(offset)
		Clone.Parent = character

		local body = Instance.new("BodyVelocity")
		body.MaxForce = Vector3.new(40000,40000,40000)
		body.Velocity = humrp.CFrame.lookVector * 10
		body.Parent = Clone

		wait(timeAmount)

		local explosion = Instance.new('Explosion')
		explosion.Parent = Clone
		explosion.Position = Clone.Position
		explosion.BlastRadius = blastRange
		wait(0.45)
		Clone:Destroy()

		Clone.Touched:Connect(function()
			local explosion = Instance.new('Explosion')
			explosion.Parent = Clone
			explosion.Position = Clone.Position
			explosion.BlastRadius = blastRange
			wait(0.45)
			Clone:Destroy()
		end)
	else
		return
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

you shouldn’t just use Touched because it would always touch something, what you want to do instead is detect if it’s a player that’s touching it.
to do this you can do:

Clone.Touched:Connect(function(hit) -- to get what is touching it
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then -- check if it's player or you can put anything
        -- your function
    end
end)

i hope this helps

Thanks! It worked, also how would I make the bomb go faster, I tried changing the body velocity max force to be higher but it still won’t go faster

what do you mean by the bomb faster? do you mean faster explotion?

Basically I am making a tool where when I activate it, a bomb spawn rolling forward and when it hit a player it will explode
So I inserted a body velocity in the bomb when I activate the tool to make it roll forward but It was slow, I tried changing the max force but it won’t go faster.

To make it faster, you change the bodyvelocity.Velocity’s magnitude, not maxforce, maxforce only applies when talking about the mass of an object, if you made it high already, this isn’t an issue, also, you had two issues with your clone.Touch, it was before all of the Explosions, and waits, you could have fixed this by putting the .Touched event before all the waits and then this error applies

please update both of these, and you’ve got yourself a perfect bomb!

Hm, How would I change the velocity magnitude? In the body.Velocity line? If so how would I change it to make it go faster because in the body.velocity line I put “humrp.CFrame.Lookvector * 10” in it so it make the bomb always go toward the direction player is facing, do I just add like a “+ Vector3.new()” in it?

just change that “10” to whatever speed you want it to be

it would be better to make a speed variable and multiply the lookvector as the new velocity

Example:

local speed = 10-- change this to whatever you want it to be

local newvelocity = HRP.CFrame.LookVector*speed

bodyvelocity.Velocity = newvelocity

and remember, the speed is measured in studs per second