I am trying to make a motorcycle that explodes if it hits a wall, however, the touched event isnt working.
Here’s the code.
function onTouched(part)
local h = part
print(h.Name)
if h ~= nil then --and --script.Parent.Parent.EngineBlock.Velocity.Magnitude >= 60 then
local boom = Instance.new("Part")
boom.CanCollide = false
boom.Locked = true
boom.Anchored = true
boom.Transparency = 1
local pow = Instance.new("Explosion")
pow.ExplosionType = Enum.ExplosionType.NoCraters
pow.Position = script.Parent.Position
pow.BlastRadius = 8
pow.Parent = boom
local bam = workspace.Boom:Clone()
bam.Parent = boom
bam:Play()
end
end
script.Parent.Touched:Connect(onTouched())
--script.Parent.Touched:connect(onTouched)