Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this Gliding script not working?

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

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! :)

2 comments

0

It worked Thank you!

0

Your link can be formatted into link text(:

This discussion is preserved as it was. New answers, comments, and votes are closed.