Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Else statement does not respond. how do i fix it?

Asked by 6 years ago

The if and elseif statements work when i tweak my variables but the final else statement does not work. Am i doing something wrong?

num = 1
num2 = 3

function ifStatement()
  if num > num2 then
      script.Parent.Size = Vector3.new(2,2,2)

  elseif num == num2 then
      script.Parent.Transparency = 0.3


  else
    script.Parent.Velocity = Vector3.new(1,0,1)
  end

end

ifStatement()
0
i dont think u can do elseif and else in a if statement not sure tacotown2 119 — 6y
0
yes you can DeceptiveCaster 3761 — 6y
0
The variable num would have to be less than num2 for the else statement to run. User#25115 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The final 'else' statement does work. IDK what the "Velocity" part of your script's parent (most probably a BasePart) does. You can add a print() function after

script.Parent.Velocity = Vector3.new(1, 0, 1)

Like this:

script.Parent.Velocity = Vector3.new(1, 0, 1)

print(script.Parent.Velocity)

It is going to print out the Velocity which, you guessed it, is 1, 0, 1. According to my knowledge, changing the velocity of a BasePart does nothing unless some special requirements are met. It just sets the Velocity, then waits for the requirement, most probably an instance, like BodyVelocity. Again, I am not sure what it does, so please correct me if you know.

Anyways, I hope my answer helped. Have a great day ahead!

Ad

Answer this question