How do I make a role chooser?

Im working on a role system where a player opens a gui and can choose a role. Sadly, the code isnt working.

local PBtool = game.ServerStorage.RoleplayTools.Potion
local roleList = game.StarterGui.ScreenGui.RoleList.ScrollingFrame.Roles

local Buttons = {
	roleList:FindFirstChild("Janitor"),
	roleList:FindFirstChild("Enforcer"),
	roleList:FindFirstChild("Assassin"),
	roleList:FindFirstChild("Guardian Angel"),
	roleList:FindFirstChild("Executioner"),
	roleList:FindFirstChild("Puppeteer"),
	roleList:FindFirstChild("Medusa"),
	roleList:FindFirstChild("Godfather"),
	roleList:FindFirstChild("Outlaw"),
	roleList:FindFirstChild("Magician"),
	roleList:FindFirstChild("Toxicologist"),
	roleList:FindFirstChild("Veteran"),
	roleList:FindFirstChild("Investigator"),
	roleList:FindFirstChild("Liberator"),
	roleList:FindFirstChild("Disrupter"),
	roleList:FindFirstChild("Townie"),
	roleList:FindFirstChild("Sheriff"),
	roleList:FindFirstChild("Executive")
}



for i, v in pairs(Buttons) do
	
	v.MouseButton1Click:Connect(function(player)
		local char = player.Character
		local head = char:WaitForChild("Head")
		
		if v == "Townie" then
			local Tgui = game.ServerStorage["RoleGui's"]:FindFirstChild("TownieGui")
			
			Tgui.Parent = head
			
		end
	end)
end

youre detecting the clicks on the buttons in StarterGui which the players dont see, all ui from StarterGui gets cloned and parented to the players PlayerGui

change

local roleList = game.StarterGui.ScreenGui.RoleList.ScrollingFrame.Roles

to

local roleList = game.Players.LocalPlayer:WaitForChild("PlayerGui").ScreenGui.RoleList.ScrollingFrame.Roles
local roleList = game.StarterGui.ScreenGui.RoleList.ScrollingFrame.Roles
local playerGui = game.Players.LocalPlayer.PlayerGui

local Buttons = {
    roleList:FindFirstChild("Janitor"),
    -- ... (other buttons)
    roleList:FindFirstChild("Executive")
}

for _, button in pairs(Buttons) do
    button.MouseButton1Click:Connect(function()
        local char = game.Players.LocalPlayer.Character
        local head = char:WaitForChild("Head")

        if button.Name == "Townie" then
            local Tgui = game.ServerStorage["RoleGui's"]:FindFirstChild("TownieGui")
            if Tgui then
                Tgui.Parent = playerGui
            else
                warn("TownieGui not found in ServerStorage.")
            end
        end
    end)
end