Add text behind variable

The title may not make sense because i dont know how to explain it. I want to make something like this:

local obj = object
game.Workspace.obj:Destroy

The object part in workspace should destroy, but its clear that this does not work. I want to have this as the same effect as this:

game.Workspace.object:Destroy

This is just a simplified example. I need to do this because i get the player name, and to be able to reference it i need to do

local variable = (player name)
game.Players.variable

If you want me to explain a bit more just say so. Thanks

1 Like

I think you’re looking for this

local Player = game.Players:FindFirstChild("StraightScared")
-- or
local Player = game.Players:WaitForChild("StraightScared")
-- or 
local Player = game.Player["StraightScared"] -- Least recommended way
local Obj = game.Workspace.Object
Obj:Destroy()
--Or
local Obj = game.Workspace:WaitForChild("Object")
Obj:Destroy()
--etc...
1 Like

Simple! Just do

local playerName = "AlexPalex178" -- choose any name
game.Players[playerName]
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.