So basically, if the player is on the table, and pressed the key W, the print should appear "Player 1 pressed the key" However, even tho I join in the table, i still get the print "Player is not in the table" any help?
ServerScript
local remote = game.ReplicatedStorage.RemoteEvent
local theTable = {}
workspace.SpawnLocation.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
table.insert(theTable, hit.Parent)
print(hit.Parent.Name.." Joined the game")
end
end)
remote.OnServerEvent:Connect(function(player, theplayer)
if theplayer.Name == table.find(theTable, 1) then
print("Player 1 pressed the key")
else
print("Player is not in table")
end
end)
Local Script
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local remote = game.ReplicatedStorage.RemoteEvent
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.W then
print("W was pressed")
remote:FireServer(player)
end
end)
