I decided to make a barrel that makes you fly away when you touch it at the right speed. *It is in a Regular script. *The error is "Script:4: attempt to compare userdata with number" This is the script:
01 | local Barrel = script.Parent.Union |
02 |
03 | function Explode(Part) |
04 | if Part.Velocity < = 1 then |
05 | local expl = Instance.new( "Explosion" ) |
06 | expl.BlastPressure = 99999999 |
07 | expl.BlastRadius = 100 |
08 | expl.DestroyJointRadiusPercent = 0 |
09 |
10 | end |
11 | end |
12 |
13 | Barrel.Touched:connect(Explode) |
The Velocity property of Part is a Vector3 value (userdata), you can't directly compare it to a number.
The Vector3 has 3 properties, X, Y and Z.
Let's assume you wanted to change the Y value.
01 | local Barrel = script.Parent.Union |
02 |
03 | function Explode(Part) |
04 | if Part.Velocity.Y < = 1 then -- Velocity.Y |
05 | local expl = Instance.new( "Explosion" ) |
06 | expl.BlastPressure = 99999999 |
07 | expl.BlastRadius = 100 |
08 | expl.DestroyJointRadiusPercent = 0 |
09 |
10 | end |
11 | end |
12 |
13 | Barrel.Touched:connect(Explode) |