The following script gets all the player's names once the script's parent (Part) is touched.
local debounce = false script.Parent.Touched:connect(function(hit) if not debounce then debounce = true local list = {} for i, plr in pairs(game.Players:GetPlayers()) do table.insert(list, plr.Name) msg = Instance.new("Message") msg.Parent = game.Workspace msg.Text = table.concat(list, "") end debounce = false end end)
What would I need to do to this script to only get 1 player's name instead of them all?
You don't need to create a table, GetPlayers already return a table. Also, that debounce is useless, because it has no wait.
local debounce = false script.Parent.Touched:connect(function(hit) if not debounce then debounce = true local list = game.Players:GetPlayers()) msg = Instance.new("Message") msg.Parent = game.Workspace msg.Text = table.concat(list, "") wait(1) -- the debounce wait debounce = false end end)