Reputation: 53
RPS = {}
RPS[1] = "Rock"
RPS[2] = "Paper"
RPS[3] = "Scissors"
function RPS()
playerOne = math.random( #RPS )
playerTwo = math.random( #RPS )
if playerOne == playerTwo then
print("It is a tie\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
elseif playerOne == RPS[1] then
if playerTwo == RPS[2] then
print("Player Two wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
else
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
end
elseif playerOne == RPS[2] then
if playerTwo == RPS[1] then
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
else
print("Player Two wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
end
else
if playerTwo == RPS[1] then
print("Player Two wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
else
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
end
end
end
print(RPS())
Don't know what's wrong with this script, appreciate some input from you guys. Although the error says on line 19:
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
That there is an expected near ')'
Upvotes: 2
Views: 1077
Reputation: 1140
There is a concatenation call (..
) at the end, but it only has one argument. Delete that and that should fix the error. Remember that concatenation means adding two strings together and it must have two arguments.
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo)
You also need to change the table name or the function name since they are conflicting.
Upvotes: 6