I'm trying to make it that when someone clicks a gui it adds them to a folder so then I can teleport them to the map and stuff. Everything in my script should work in the way I see it but I keep getting this error that I dont understand:
Players.epicnmac.PlayerGui.PartySystem.Frame.Frame.TextButton.LocalScript:4: attempt to index nil with 'Parent'
My code is in a starter gui and is a local script. This is my code:
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Name
local char = player.Character
function OnClicked()
char.Parent = game.Workspace.PlayersMap
end
script.Parent.MouseButton1Down:connect(OnClicked)
Why does it give me an error? What do I have to do different to make it work?

2 comments
If your confused on what PlayersMap is, its just a folder in workspace.
It could be because you're using .Name for the player variable which would mean that it is not an object in workspace? Not sure if that's the correct answer, but I'd try removing the .Name