Idea is, if the players on the table, press the randomed Chosen Key, they get a point. If First Player pressed it, it should prints "First Player Clicked me" If Second Player Pressed it, it Shoulld print "Second Player clicked me" However, it's not working and im not getting any error

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)]
print(randomKeyChooser)
local isThereAWinner = false


UIS.InputBegan:Connect(function(key)


local ClickForRoomOne = workspace.RoomsToJoin.RoomOne.RoomOneClick											-- ROOM ONE
local playersInRoomOne = {}

ClickForRoomOne.MouseClick:Connect(function(click)
	table.insert(playersInRoomOne, click)
end)

    if key.KeyCode == Enum.KeyCode[randomKeyChooser] then
		if key == playersInRoomOne[1] then
			print("First player clicked me")
		end
		
		if key == playersInRoomOne[2] then
			print("Second player clicked it")
		end
	end
end)

1 comment

0

‘Key’ is an InputObject, it doesn’t match a Client. UserInputService can only be operated singularly on each Player, so you couldn’t check if the Input came someone else. You would need to fire a Remote and debounce after a first connection, you can use the PlayerFired parameter to denote the Player the hit the key first.