Car not exploding on touch

I have attempted to make a script (multiple times now) that explodes a car when a part of it touches something. I have searched Youtube and followed tutorials but nothing seemed to work.

Here’s a video of what happens:
robloxapp-20240430-1704102.wmv (2.0 MB)

The script

local Part = script.Parent
local Car = Part.Parent

Part.Touched:Connect(function(hit)
	Part.Anchored = true
	Part.CanCollide = false
	Part.Transparency = 0
	
	local Explosion = Instance.new("Explosion")
	Explosion.Position = Part.Position
	Explosion.BlastRadius = 10
	Explosion.BlastPressure = 1000000
	Explosion.Parent = Part
	
	Part:Destroy()
end)

Thank for helping! (if you did :cry:)

Check if there is an enable property, I’ve haven’t coded explosions in ages so I’m not 100% sure

no, there is no “Enabled” property

1 Like

What part is that? I mean the one that when get touched it should create the explosion? Its the main base of the car?
Cause your script should cause an explosion even when its touched by the player. Meaning that if you get on it and it doesnt explode the Touched event is not even firing it.

Is the part able to be touched? add prints to verify that the touch event at least fires

watch the video please! :sad: (please review whole post before asking for more info) (Its the half see through red part out the front obv)

I already watched the video, you jump into the car and it doesnt explode… And your script should cause that the explosion happens even when the player touch it, and actually lot of times cause you are not using debouces, and the part where you are parenting the explosion you are destroying it right away.

Before fixing all those issues… You gotta make sure that the Touched event is even firing. I already read your entire post and watch the video. I suggest first add prints and be sure that the Touched event fires, cause according to the video and using that script the event should fire multiple times. Perhaps the part has no touch enabled, maybe the part is unreachable for the touch event.

First try debugging before thinking others didnt read your post…

local Part = script.Parent
local Car = Part.Parent

task.wait(3)
Part.Touched:Connect(function(hit)
	Part.Anchored = true
	Part.CanCollide = false
	Part.Transparency = 0
	
	local Explosion = Instance.new("Explosion")
	Explosion.Position = Part.Position
	Explosion.BlastRadius = 10
	Explosion.BlastPressure = 1000000
	Explosion.Parent = Part
	
	Part:Destroy()
end)

It might be because the explosion is happening instantly as soon as the server starts because it’ll already be touching something, so maybe delaying it might work.

1 Like

It does the same thing im confused :confused:

Hey thanx! I saw your edit in your reply now. So its the red part. Ok, then it should not explode when you character jumps in. Still, add prints otherwise you dont know if the touch event fires. If you dont see the print the problem is the Touch event

If the explosion already happen, then why the red box still there if the function is destroying it?
Part:Destroy()

ik it touches because the part is destroyed…

Then try to not destroy it right away, I already said it. You would be destroying the explosion which is inside that part too.

Why not parenting else where? or do not destroy the part instantly on touch?

Thanks for the help. :+1: helped a lot

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.