Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to use a variable in an explorer pathway?

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]

1 answer

✓ Accepted answer

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.