I have a string value that was inserted into the workspace called "Players". When a player is added into the game it create another string value having the parent be "Players" However it keeps giving this output and will not work. 17:31:19.224 - Workspace.PLR:9: attempt to call field 'Players' (a userdata value).
game.Players.PlayerAdded:connect(function(plr)
wait(.5)
local k = Instance.new("StringValue",game.Workspace.Players)
k.Name = plr.Name
k.Value = plr.Name
end)
game.Players.PlayerRemoving:connect(function(plr2)
if game.Workspace.Players:FindFirstChild(plr2.Name) then
game.Workspace.Players(plr2.Name):remove()
end
end)

2 comments
On line 9, use FindFirstChild or square brackets. Ex, game.Workspace.Players:FindFirstChild(plr2.Name):Destroy()
Square brackets = [ ]