I am trying to make a simple elevator using CFrame, as I am just starting out with LUA. I am trying to make it so when you chat a message the script will execute, but it is just not working. I know it is a long script, but I haven't figured out how to shorten it.
p.Chatted:connect(function(msg)
if msg=="://Down" then
game.Workspace.Part1.CFrame = CFrame.new(0, 56, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 55, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 50, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 45, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 40, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 35, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 30, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 25, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 20, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 15, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 10, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 5, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 0, 0.5)
wait (.1)
elseif msg=="://Up" then
game.Workspace.Part1.CFrame = CFrame.new(0, 0, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 5, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 10, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 15, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 20, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 25, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 30, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 35, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 40, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 45, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 50, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 55, 0.5)
wait (.1)
game.Workspace.Part1.CFrame = CFrame.new(0, 56, 0.5)
wait (.1)
(end
end)
