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

Why is this Gliding script not working?

Asked by 9 years ago

What did I do wrong? This script seems to break on line 4.

function Glide(CurrentPos,TargetPos,speed)
    if CurrentPos < TargetPos then
        return math.min(TargetPos,CurrentPos + speed)
    elseif CurrentPos > TargetPos
        return math.max(TargetPos,CurrentPos - speed)
    else
        return TargetPos
    end
 end

 Glide(CurrentPos,TargetPos,speed)

1 answer

Log in to vote
2
Answered by
LostPast 253 Moderation Voter
9 years ago

On Line 4 you forgot to use a then. It will not check without the entire if then statement. Then Closes the statement.

http://wiki.roblox.com/index.php?title=Conditional_statement#Elseif

function Glide(CurrentPos,TargetPos,speed)
    if CurrentPos < TargetPos then
        return math.min(TargetPos,CurrentPos + speed)
    elseif CurrentPos > TargetPos then
        return math.max(TargetPos,CurrentPos - speed)
    else
        return TargetPos
    end
 end

 Glide(CurrentPos,TargetPos,speed)

Hope this helps! :)

0
It worked Thank you! Tyfoomerang360 0 — 9y
0
Your link can be formatted into link text(: Goulstem 8144 — 9y
Ad

Answer this question