Detect if a part has collided in a certain speed

I’m currently making a Vehicle crash script for my Aircraft, it works if the hitbox collides when it reaches the target speed.

This is what i have tried so far but didn’t work. (Not a Local Script)

local Seat = script.Parent.Parent.DriveSeat
local Particle = script.Parent.DestroyedParticle
local Hitbox = script.Parent.Parent.Collision

Hitbox.Touched:Connect(function(hit)
	if Seat.Velocity.Magnitude >= 1 and hit.Name == "Hitbox" then
		Particle.Enabled = true
		print("Enabled")
	else
		Particle.Enabled = false
		print("Disabled")
	end
end)
5 Likes

Your detecting if the colliders name is hitbox.

5 Likes

for checking the speed you could use the velocity of the object to check its speed and the direction its moving in

3 Likes

I named the collision part Hitbox.

4 Likes

Already? i used Velocity.Magnitude

4 Likes

Yes, you did. Your checking if the part it collided with is named Hitbox. Hitbox can’t touch itself.

4 Likes

The variable “hit” in your function represents the part that collided with the part your detecting .Touched on.

3 Likes

Wait now I don’t get it… so shouldn’t my script work?

3 Likes

Your script wont work. Remove the check for the parts name and see.

3 Likes

You mean the “Local Hitbox” thing?

3 Likes

image
this

3 Likes

So do i just remove this part?

image

3 Likes

not the “then” part but yes, that is part you deleter

4 Likes

It actually worked… I never knew something little like that could mess a script. Thanks!

4 Likes

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