So basically, I'm trying to make it, that only the players that are in a table, if they click the random chosen key, they teleport.
How can I access a table on LocalScript
local UserInputService = game:GetService("UserInputService")
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 remote = game.ReplicatedStorage.Remote2
local chosenKey = list[math.random(1, #list)]
UIS.InputBegan:Connect(function(key, gpe)
if gpe then return end
if key.KeyCode = Enum.KeyCode[chosenkey] then
remote:FireServer()
end
end)
--//SERVERSCRIPT HERE\\--
local redPlayers = {}
workspace.Part.Touched:Connect(function(hit)
table.insert(redPlayers, hit.Parent)
local remote = game.ReplicatedStorage.remot2
local cooldown = {}
remote.OnServerEvent:Connect(function(hit)
local enemyplr = hit.Parent:FindFirstChild('HumanoidRootPart')
if enemyplr then
-- if enemyplr == char:FindFirstChild('Humanoid') then return end
if not cooldown[enemyplr] then
cooldown[enemyplr] = true
enemyplr.CFrame = 0, 0, 0
end
end)

1 comment
Use a Module Script or Dictionary