game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,Text)
print(Text)
end)
Is it possible to add a line of code like this game.Players.[I want to use the variable here]
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,Text)
print(Text)
end)
Is it possible to add a line of code like this game.Players.[I want to use the variable here]
You can do this by adding brackets [] at the end of an object, like this:
local player = "Player123"
game.Players[player]:Kick("Example")
This can be useful for manipulating string like this:
-- Assuming there's a player called Player123 and yer123
local player = game.Players.Player123
local bot = string.sub(player.Name, 4) -- should be 'yer123'
if not player:FindFirstChild(bot) then return end
game.Players[bot]:Kick("Example")
This discussion is preserved as it was. New answers, comments, and votes are closed.