RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make rock paper siccsors"
-- server script local players = game:GetService("Players") local playerChoices = {} local gameStarted = false local function determineWinner() local choices = {} for player, choice in pairs(playerChoices) do table.insert(choices, choice) end if #choices ~= #players:GetPlayers() then return end gameStarted = false local winner if choices[1] == "rock" and choices[2] == "scissors" or choices[1] == "paper" and choices[2] == "rock" or choices[1] == "scissors" and choices[2] == "paper" then winner = players:GetPlayerFromCharacter(playerChoices[1].Parent) elseif choices[1] == choices[2] then return else winner = players:GetPlayerFromCharacter(playerChoices[2].Parent) end -- award winner if winner then local coins = winner.leaderstats.Coins coins.Value = coins.Value + 10 end -- reset choices for player, choice in pairs(playerChoices) do playerChoices[player] = nil end end local function onButton1Down(player) if not gameStarted then gameStarted = true playerChoices[player] = script.Parent.Name script.Parent.Text = "Waiting for opponent..." else playerChoices[player] = script.Parent.Name determineWinner() end end script.Parent.MouseButton1Down:Connect(function() onButton1Down(players:GetPlayerFromCharacter(script.Parent.Parent)) end)