Edit: I just want to know, how to check which player Pressed the key
So Basically, If First player on the table, Pressed the key, let's say a print happens. How can I Do That?
I tried = if i[1].key.KeyCode == Enum.KeyCode[playersInRoomOne] then but it's not working, I don't get any errors
Local Script
local remote = game.ReplicatedStorage.RoomsStringValues.RoomOne.RoomOneEvent local UIS = game:GetService("UserInputService") local playerOneString = game.ReplicatedStorage.RoomsStringValues.RoomOne.PlayerOne local playerTwoString = game.ReplicatedStorage.RoomsStringValues.RoomOne.PlayerTwo local playersInRoomOne = {playerOneString, playerTwoString} local allTheKeyWords = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X","Y","Z"} local randomKeyChooser = allTheKeyWords[math.random(1, #allTheKeyWords)] local isThereAWinner = false print("Players in game are: "..table.concat(playersInRoomOne, ", ")) UIS.InputBegan:Connect(function(key) -- The Code should be here for player 1 if key.KeyCode == Enum.KeyCode[randomKeyChooser] then print("Player 1 pressed it") else print("Player 2 pressed it") end end)
killerbrenden is probably right. You'd probably want a remote that sets a variable to true, that variable meaning that the player pushed the button. However, if this is the right answer, you might wanna get killerbrenden to put an answer in, cause it's what he suggested
I'll take a guess. A pretty good way is creating a blank table:
local blank = {}
I used a click detector in place, but it should work the same.
Get when the player pressed the key (or in my case clicked the part) and create a function:
script.Parent.ClickDetector.MouseClick:Connect(function(player) end)
Put in the function something like this:
table.insert(blank,player.Name) for i, v in pairs(blank) do print(i,v) end
The total script:
local blank = {} script.Parent.ClickDetector.MouseClick:Connect(function(player) table.insert(blank,player.Name) for i, v in pairs(blank) do print(i,v) end end)