How can I set a certain range of values for my script?
Basically I want a property to change if the velocity of another brick hitting it is greater than 30, but lower than 90. I try this and even if it the part travels at 100 speed, it still gets its property changed.
local B1 = script.Parent.Parent.Parent.Car.B1
local HitBox = script.Parent
HitBox.Touched:Connect(function(Part)
if Part.Name == "B1" and Part.Velocity.Magnitude >= 30 and Part.Velocity.Magnitude <= 90 then
print("It is B1!")
script.Parent.Parent.B2.Transparency = 0
script.Parent.Parent.B2.CanCollide = true
script.Parent.Parent.B1.Transparency = 1
script.Parent.Parent.B1.CanCollide = false
else
if Part.Name == "B1" and Part.Velocity.Magnitude >= 90 then
print("It is B1!")
script.Parent.Parent.B1.Transparency = 1
script.Parent.Parent.B1.CanCollide = false
print("It isn't B1, it is ".. Part.Name .."!")
end
end
end)

2 comments
Well your elseif statement specifically allows velocity over 90. I'm not gonna answer since you didn't explain that.
Maybe I would've explained it if I realized. Don't jump to conclusions buddy.