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)

4 comments
Thank you accept I want the second part to be only if the speed is greater than 90, so the first part between 30 and 90, and the second part after "else" to be higher than 90
But I don't want it to activate if it is under 30 speed. Right now if it gets hit even at 1 speed it changes which is weird.
script edited, try now
Now it doesn't work at all, this is really weird. Idk why roblox does this