--Detect when a player is added.

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function()
		repeat wait() until player.Character
		local char = player.Character
	
		--Insert gui into player.
		local gui = guibase:Clone()
		gui.Parent = player.PlayerGui
	
		--Setup name.
		local mod = Instance.new("Model")
		local hum = Instance.new("Humanoid")
		local head = Instance.new("Part")
	
		--Insert humanoid into model.
		hum.Parent = mod
	
		--Set initial name to be blank.
		mod.Name = ""
	
		--Set head properties.
		head.Size = Vector3.new(1,1,1)
		head.CanCollide = false
		head.Transparency = 0.99
		head.Name = "Head"
		head.Parent = mod
			
		--Finish model setup.
		mod.PrimaryPart = head
		mod.Parent = char
		mod:SetPrimaryPartCFrame(char.Head.CFrame+Vector3.new(0,0.5,0))
		
		--Weld part to character.
		local w = Instance.new("Weld")
		w.Name = ("Weld")
		w.Part0,w.Part1 = head,char.Head
		w.C0 = head.CFrame:inverse()
		w.C1 = char.Head.CFrame:inverse()
		w.Parent = head
		
		--Add server side handling to model.
		local svh = gui.ServerHandler
		svh.Parent = mod
		svh.ServerHandler.Disabled = false
		gui.HandlerPointer.Value = svh
		
		--Enable local handler to finish setup.
		gui.LocalHandler.Disabled = false
	end)
end)
