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

Can someone help me fix this script?

Asked by 10 years ago

Someone was helping me about 2 days ago and sent me this script. It states that "While X < maxpos do" is an Error. I cannot figure out how to edit this to make it correct, please help.

local speed = 0.07 -- how much the brick moves each tick

local waittime = 0.25 --How much time there is between each tick.

X = Workspace.Model.Part.Position.X -- make sure this is the brick you based coordinates on.

minpos = 10 --Minimum position, this is 10 in this case

maxpos = 20 --Maximum position, this is 20 in this case

model = Workspace.Model --the model you want to move.

function clicked()

if X < maxpos then

While X < maxpos do

model:MoveTo(X + Vector3.new(speed,0,0))

X = X --Update the Variable

if X > maxpos then x = maxpos --Check, to make sure it won't outpass its limit on the last tick.

end

wait(waittime)

end

else

While X > minpos do

model:MoveTo(X - Vector3.new(speed,0,0))

X = X -- update the variable.

if X < minpos then x = minpos --Check, to make sure it won't outpass its limit on the last tick.

end

wait(waittime)

end

end Workspace.Model.Part.ClickDetector:connect(clicked) -- Clickdetectors can only be used in parts. so those wich brick should be clicked wisely

Answer this question