Basically, The Idea of the game is, the first player to Press the Randomed Generated Key, wins the points, however, I must do it via LocalScript, so I must use Remote Events, but It's not working. What am I doing wrong
ServerScriptStorage
-- DEFINE CLICKDETECTORS
local ClickForRoomOne = workspace.RoomsToJoin.RoomOne.RoomOneClick
local remoteEvent = game.ReplicatedStorage.RemoteEvent
-- ROOM ONE
--DEFINE THE TABLE
local playersInRoomOne = {}
ClickForRoomOne.MouseClick:Connect(function(click)
if #playersInRoomOne < 2 then
-- PLAYER JOINS ROOMS
--IF PLAYER IS ALREADY ON THE TABLE
if table.find(playersInRoomOne, click) then
print("You are already in the table!")
else -- IF PLAYER IS NOT ON TABLE ALREADY
table.insert(playersInRoomOne, click)
local RoomOnePlayerOnePoints = 0
local RoomOnePlayerTwoPoints = 0
end
-- GAME STARTS -------------------------------
if #playersInRoomOne == 2 then
print("Game Starting")
remoteEvent:FireServer()
end
end)
StarterGUI (Local Script)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest")
local ClickForRoomOne = workspace.RoomsToJoin.RoomOne.RoomOneClick
local playersInRoomOne = {}
ClickForRoomOne.MouseClick:Connect(function(click)
table.insert(playersInRoomOne, click)
end)
local RoomOnePlayerOnePoints = 0
local RoomOnePlayerTwoPoints = 0
list = {"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 chosenKey = list[math.random(1, #list)]
print(chosenKey)
remoteEvent.OnServerEvent:Connect(function()
UserInputService.InputBegan:Connect(function(key)
if [playersInRoomOne[1]]key.KeyCode == Enum.KeyCode[chosenKey] then
RoomOnePlayerOnePoints = RoomOnePlayerOnePoints + 1
end
if [playersInRoomOne[2]]key.KeyCode == Enum.KeyCode[chosenKey] then
local RoomOnePlayerTwoPoints = local RoomOnePlayerTwoPoints + 1
end
end)
end)

1 comment
It's still not working :( can you maybe add me discord so we can both fix this problem! Aft3rL1fe#8610