RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make rock paper siccsors"
-- server script for rock paper scissors game local players = game:GetService("Players") local playerChoices = {} local gameStarted = false local choices = {"rock", "paper", "scissors"} local function checkWinner() local player1 = players:GetPlayerByUserId(playerChoices[1].UserId) local player2 = players:GetPlayerByUserId(playerChoices[2].UserId) local player1Choice = playerChoices[1].Choice local player2Choice = playerChoices[2].Choice if player1Choice == player2Choice then print("Tie!") elseif (player1Choice == "rock" and player2Choice == "scissors") or (player1Choice == "paper" and player2Choice == "rock") or (player1Choice == "scissors" and player2Choice == "paper") then print(player1.Name .. " wins!") else print(player2.Name .. " wins!") end playerChoices = {} gameStarted = false end local function startGame() gameStarted = true wait(5) if #playerChoices == 2 then checkWinner() else playerChoices = {} gameStarted = false end end local function onChosen(player, choice) if gameStarted or not table.find(choices, choice) then return end table.insert(playerChoices, {UserId = player.UserId, Choice = choice}) if #playerChoices == 2 then startGame() end end players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(msg) onChosen(player, msg) end) end)